Skip to content

Commit

Permalink
IB/IPoIB: Support acceleration options callbacks
Browse files Browse the repository at this point in the history
IPoIB driver now uses the new set of callback functions.

If the hardware provider supports the new ipoib_options implementation,
the driver uses the callbacks in its data path flows, otherwise it uses the
driver default implementation for all data flows in its code.

The default implementation wasn't change and it is exactly as it was before
introduction of acceleration support.

Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Reviewed-by: Alex Vesker <valex@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
Erez Shitrit authored and Doug Ledford committed Apr 20, 2017
1 parent c1048af commit cd565b4
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 76 deletions.
29 changes: 18 additions & 11 deletions drivers/infiniband/ulp/ipoib/ipoib.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#include <rdma/ib_pack.h>
#include <rdma/ib_sa.h>
#include <linux/sched.h>

/* constants */

enum ipoib_flush_level {
Expand Down Expand Up @@ -153,8 +152,12 @@ static inline void skb_add_pseudo_hdr(struct sk_buff *skb)
skb_pull(skb, IPOIB_HARD_LEN);
}

/* Keep the refactoring compile able */
#define ipoib_priv netdev_priv
static inline struct ipoib_dev_priv *ipoib_priv(const struct net_device *dev)
{
struct rdma_netdev *rn = netdev_priv(dev);

return rn->clnt_priv;
}

/* Used for all multicast joins (broadcast, IPv4 mcast and IPv6 mcast) */
struct ipoib_mcast {
Expand Down Expand Up @@ -407,6 +410,7 @@ struct ipoib_dev_priv {
struct timer_list poll_timer;
unsigned max_send_sge;
bool sm_fullmember_sendonly_support;
const struct net_device_ops *rn_ops;
};

struct ipoib_ah {
Expand Down Expand Up @@ -485,25 +489,26 @@ int ipoib_open(struct net_device *dev);
int ipoib_add_pkey_attr(struct net_device *dev);
int ipoib_add_umcast_attr(struct net_device *dev);

void ipoib_send(struct net_device *dev, struct sk_buff *skb,
struct ipoib_ah *address, u32 dqpn);
int ipoib_send(struct net_device *dev, struct sk_buff *skb,
struct ib_ah *address, u32 dqpn);
void ipoib_reap_ah(struct work_struct *work);

struct ipoib_path *__path_find(struct net_device *dev, void *gid);
void ipoib_mark_paths_invalid(struct net_device *dev);
void ipoib_flush_paths(struct net_device *dev);
int ipoib_check_sm_sendonly_fullmember_support(struct ipoib_dev_priv *priv);
struct ipoib_dev_priv *ipoib_intf_alloc(const char *format);

struct ipoib_dev_priv *ipoib_intf_alloc(struct ib_device *hca, u8 port,
const char *format);
void ipoib_ib_tx_timer_func(unsigned long ctx);
void ipoib_ib_dev_flush_light(struct work_struct *work);
void ipoib_ib_dev_flush_normal(struct work_struct *work);
void ipoib_ib_dev_flush_heavy(struct work_struct *work);
void ipoib_pkey_event(struct work_struct *work);
void ipoib_ib_dev_cleanup(struct net_device *dev);

void ipoib_dev_uninit_default(struct net_device *dev);
int ipoib_ib_dev_open_default(struct net_device *dev);
int ipoib_ib_dev_open(struct net_device *dev);
int ipoib_ib_dev_stop(struct net_device *dev);
void ipoib_ib_dev_up(struct net_device *dev);
void ipoib_ib_dev_down(struct net_device *dev);
int ipoib_ib_dev_stop_default(struct net_device *dev);
Expand Down Expand Up @@ -566,8 +571,10 @@ void ipoib_path_iter_read(struct ipoib_path_iter *iter,
struct ipoib_path *path);
#endif

int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
union ib_gid *mgid, int set_qkey);
int ipoib_mcast_attach(struct net_device *dev, struct ib_device *hca,
union ib_gid *mgid, u16 mlid, int set_qkey, u32 qkey);
int ipoib_mcast_detach(struct net_device *dev, struct ib_device *hca,
union ib_gid *mgid, u16 mlid);
void ipoib_mcast_remove_list(struct list_head *remove_list);
void ipoib_check_and_add_mcast_sendonly(struct ipoib_dev_priv *priv, u8 *mgid,
struct list_head *remove_list);
Expand All @@ -591,7 +598,7 @@ void __exit ipoib_netlink_fini(void);
void ipoib_set_umcast(struct net_device *ndev, int umcast_val);
int ipoib_set_mode(struct net_device *dev, const char *buf);

void ipoib_setup(struct net_device *dev);
void ipoib_setup_common(struct net_device *dev);

void ipoib_pkey_open(struct ipoib_dev_priv *priv);
void ipoib_drain_cq(struct net_device *dev);
Expand Down
52 changes: 30 additions & 22 deletions drivers/infiniband/ulp/ipoib/ipoib_ib.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,8 @@ static inline int post_send(struct ipoib_dev_priv *priv,
return ib_post_send(priv->qp, &priv->tx_wr.wr, &bad_wr);
}

void ipoib_send(struct net_device *dev, struct sk_buff *skb,
struct ipoib_ah *address, u32 dqpn)
int ipoib_send(struct net_device *dev, struct sk_buff *skb,
struct ib_ah *address, u32 dqpn)
{
struct ipoib_dev_priv *priv = ipoib_priv(dev);
struct ipoib_tx_buf *tx_req;
Expand All @@ -554,7 +554,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
++dev->stats.tx_dropped;
++dev->stats.tx_errors;
dev_kfree_skb_any(skb);
return;
return -1;
}
} else {
if (unlikely(skb->len > priv->mcast_mtu + IPOIB_ENCAP_LEN)) {
Expand All @@ -563,7 +563,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
++dev->stats.tx_dropped;
++dev->stats.tx_errors;
ipoib_cm_skb_too_long(dev, skb, priv->mcast_mtu);
return;
return -1;
}
phead = NULL;
hlen = 0;
Expand All @@ -574,15 +574,15 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
++dev->stats.tx_dropped;
++dev->stats.tx_errors;
dev_kfree_skb_any(skb);
return;
return -1;
}
/* Does skb_linearize return ok without reducing nr_frags? */
if (skb_shinfo(skb)->nr_frags > usable_sge) {
ipoib_warn(priv, "too many frags after skb linearize\n");
++dev->stats.tx_dropped;
++dev->stats.tx_errors;
dev_kfree_skb_any(skb);
return;
return -1;
}
}

Expand All @@ -602,7 +602,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
if (unlikely(ipoib_dma_map_tx(priv->ca, tx_req))) {
++dev->stats.tx_errors;
dev_kfree_skb_any(skb);
return;
return -1;
}

if (skb->ip_summed == CHECKSUM_PARTIAL)
Expand All @@ -621,7 +621,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
skb_dst_drop(skb);

rc = post_send(priv, priv->tx_head & (ipoib_sendq_size - 1),
address->ah, dqpn, tx_req, phead, hlen);
address, dqpn, tx_req, phead, hlen);
if (unlikely(rc)) {
ipoib_warn(priv, "post_send failed, error %d\n", rc);
++dev->stats.tx_errors;
Expand All @@ -630,16 +630,19 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
dev_kfree_skb_any(skb);
if (netif_queue_stopped(dev))
netif_wake_queue(dev);
rc = 0;
} else {
netif_trans_update(dev);

address->last_send = priv->tx_head;
rc = priv->tx_head;
++priv->tx_head;
}

if (unlikely(priv->tx_outstanding > MAX_SEND_CQE))
while (poll_tx(priv))
; /* nothing */

return rc;
}

static void __ipoib_reap_ah(struct net_device *dev)
Expand Down Expand Up @@ -714,7 +717,7 @@ int ipoib_ib_dev_stop_default(struct net_device *dev)
struct ipoib_tx_buf *tx_req;
int i;

if (test_and_clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags))
if (test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags))
napi_disable(&priv->napi);

ipoib_cm_dev_stop(dev);
Expand Down Expand Up @@ -785,8 +788,11 @@ int ipoib_ib_dev_stop_default(struct net_device *dev)

int ipoib_ib_dev_stop(struct net_device *dev)
{
ipoib_ib_dev_stop_default(dev);
struct ipoib_dev_priv *priv = ipoib_priv(dev);

priv->rn_ops->ndo_stop(dev);

clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
ipoib_flush_ah(dev);

return 0;
Expand All @@ -811,23 +817,20 @@ int ipoib_ib_dev_open_default(struct net_device *dev)
ret = ipoib_ib_post_receives(dev);
if (ret) {
ipoib_warn(priv, "ipoib_ib_post_receives returned %d\n", ret);
goto dev_stop;
goto out;
}

ret = ipoib_cm_dev_open(dev);
if (ret) {
ipoib_warn(priv, "ipoib_cm_dev_open returned %d\n", ret);
goto dev_stop;
goto out;
}

if (!test_and_set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags))
if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags))
napi_enable(&priv->napi);

return 0;
dev_stop:
if (!test_and_set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags))
napi_enable(&priv->napi);
ipoib_ib_dev_stop(dev);
out:
return -1;
}

Expand All @@ -847,16 +850,21 @@ int ipoib_ib_dev_open(struct net_device *dev)
queue_delayed_work(priv->wq, &priv->ah_reap_task,
round_jiffies_relative(HZ));

if (ipoib_ib_dev_open_default(dev)) {
if (priv->rn_ops->ndo_open(dev)) {
pr_warn("%s: Failed to open dev\n", dev->name);
goto stop_ah_reap;
goto dev_stop;
}

set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);

return 0;

stop_ah_reap:
dev_stop:
set_bit(IPOIB_STOP_REAPER, &priv->flags);
cancel_delayed_work(&priv->ah_reap_task);
set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
napi_enable(&priv->napi);
ipoib_ib_dev_stop(dev);
return -1;
}

Expand Down Expand Up @@ -1241,7 +1249,7 @@ void ipoib_ib_dev_cleanup(struct net_device *dev)

clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);

ipoib_dev_uninit_default(dev);
priv->rn_ops->ndo_uninit(dev);

if (priv->pd) {
ib_dealloc_pd(priv->pd);
Expand Down
Loading

0 comments on commit cd565b4

Please sign in to comment.