RDMA/device: Add ib_device_set_netdev() as an alternative to get_netdev

The associated netdev should not actually be very dynamic, so for most
drivers there is no reason for a callback like this. Provide an API to
inform the core code about the net dev affiliation and use a core
maintained data structure instead.

This allows the core code to be more aware of the ndev relationship which
will allow some new APIs based around this.

This also uses locking that makes some kind of sense, many drivers had a
confusing RCU lock, or missing locking which isn't right.

Signed-off-by: Jason Gunthorpe <[email protected]>
This commit is contained in:
Jason Gunthorpe 2019-02-12 21:12:50 -07:00
commit c2261dd76b
6 changed files with 171 additions and 38 deletions

View file

@ -2204,6 +2204,9 @@ struct ib_port_data {
struct list_head pkey_list;
struct ib_port_cache cache;
spinlock_t netdev_lock;
struct net_device *netdev;
};
/* rdma netdev type - specifies protocol type */
@ -3996,6 +3999,10 @@ void ib_device_put(struct ib_device *device);
struct net_device *ib_get_net_dev_by_params(struct ib_device *dev, u8 port,
u16 pkey, const union ib_gid *gid,
const struct sockaddr *addr);
int ib_device_set_netdev(struct ib_device *ib_dev, struct net_device *ndev,
unsigned int port);
struct net_device *ib_device_netdev(struct ib_device *dev, u8 port);
struct ib_wq *ib_create_wq(struct ib_pd *pd,
struct ib_wq_init_attr *init_attr);
int ib_destroy_wq(struct ib_wq *wq);