aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/ulp
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2008-01-25 17:15:24 -0500
committerRoland Dreier <rolandd@cisco.com>2008-01-25 17:15:24 -0500
commit7b3687df66cab4ecd6efb42cfa0c7de60cc4e3b9 (patch)
tree8a5369a9fb1d4c645833852bec9d29bf3319e5ea /drivers/infiniband/ulp
parent1efb61444ca3a598dfafb7a6c573c5d5d42d3432 (diff)
IPoIB/cm: Factor out ipoib_cm_create_srq()
Factor out the code to create an SRQ and allocate the receive ring in ipoib_cm_dev_init() into a new function ipoib_cm_create_srq(). This will make the code neater when support for devices that don't implement SRQs is added. Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/ulp')
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 388f0413fcb..9edc9fc9621 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -1271,7 +1271,7 @@ int ipoib_cm_add_mode_attr(struct net_device *dev)
1271 return device_create_file(&dev->dev, &dev_attr_mode); 1271 return device_create_file(&dev->dev, &dev_attr_mode);
1272} 1272}
1273 1273
1274int ipoib_cm_dev_init(struct net_device *dev) 1274static int ipoib_cm_create_srq(struct net_device *dev)
1275{ 1275{
1276 struct ipoib_dev_priv *priv = netdev_priv(dev); 1276 struct ipoib_dev_priv *priv = netdev_priv(dev);
1277 struct ib_srq_init_attr srq_init_attr = { 1277 struct ib_srq_init_attr srq_init_attr = {
@@ -1280,6 +1280,31 @@ int ipoib_cm_dev_init(struct net_device *dev)
1280 .max_sge = IPOIB_CM_RX_SG 1280 .max_sge = IPOIB_CM_RX_SG
1281 } 1281 }
1282 }; 1282 };
1283 int ret;
1284
1285 priv->cm.srq = ib_create_srq(priv->pd, &srq_init_attr);
1286 if (IS_ERR(priv->cm.srq)) {
1287 ret = PTR_ERR(priv->cm.srq);
1288 priv->cm.srq = NULL;
1289 return ret;
1290 }
1291
1292 priv->cm.srq_ring = kzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring,
1293 GFP_KERNEL);
1294 if (!priv->cm.srq_ring) {
1295 printk(KERN_WARNING "%s: failed to allocate CM ring (%d entries)\n",
1296 priv->ca->name, ipoib_recvq_size);
1297 ib_destroy_srq(priv->cm.srq);
1298 priv->cm.srq = NULL;
1299 return -ENOMEM;
1300 }
1301
1302 return 0;
1303}
1304
1305int ipoib_cm_dev_init(struct net_device *dev)
1306{
1307 struct ipoib_dev_priv *priv = netdev_priv(dev);
1283 int ret, i; 1308 int ret, i;
1284 1309
1285 INIT_LIST_HEAD(&priv->cm.passive_ids); 1310 INIT_LIST_HEAD(&priv->cm.passive_ids);
@@ -1297,22 +1322,6 @@ int ipoib_cm_dev_init(struct net_device *dev)
1297 1322
1298 skb_queue_head_init(&priv->cm.skb_queue); 1323 skb_queue_head_init(&priv->cm.skb_queue);
1299 1324
1300 priv->cm.srq = ib_create_srq(priv->pd, &srq_init_attr);
1301 if (IS_ERR(priv->cm.srq)) {
1302 ret = PTR_ERR(priv->cm.srq);
1303 priv->cm.srq = NULL;
1304 return ret;
1305 }
1306
1307 priv->cm.srq_ring = kzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring,
1308 GFP_KERNEL);
1309 if (!priv->cm.srq_ring) {
1310 printk(KERN_WARNING "%s: failed to allocate CM ring (%d entries)\n",
1311 priv->ca->name, ipoib_recvq_size);
1312 ipoib_cm_dev_cleanup(dev);
1313 return -ENOMEM;
1314 }
1315
1316 for (i = 0; i < IPOIB_CM_RX_SG; ++i) 1325 for (i = 0; i < IPOIB_CM_RX_SG; ++i)
1317 priv->cm.rx_sge[i].lkey = priv->mr->lkey; 1326 priv->cm.rx_sge[i].lkey = priv->mr->lkey;
1318 1327
@@ -1323,6 +1332,10 @@ int ipoib_cm_dev_init(struct net_device *dev)
1323 priv->cm.rx_wr.sg_list = priv->cm.rx_sge; 1332 priv->cm.rx_wr.sg_list = priv->cm.rx_sge;
1324 priv->cm.rx_wr.num_sge = IPOIB_CM_RX_SG; 1333 priv->cm.rx_wr.num_sge = IPOIB_CM_RX_SG;
1325 1334
1335 ret = ipoib_cm_create_srq(dev);
1336 if (ret)
1337 return ret;
1338
1326 for (i = 0; i < ipoib_recvq_size; ++i) { 1339 for (i = 0; i < ipoib_recvq_size; ++i) {
1327 if (!ipoib_cm_alloc_rx_skb(dev, i, IPOIB_CM_RX_SG - 1, 1340 if (!ipoib_cm_alloc_rx_skb(dev, i, IPOIB_CM_RX_SG - 1,
1328 priv->cm.srq_ring[i].mapping)) { 1341 priv->cm.srq_ring[i].mapping)) {