diff options
Diffstat (limited to 'drivers/net/cnic.c')
-rw-r--r-- | drivers/net/cnic.c | 782 |
1 files changed, 663 insertions, 119 deletions
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c index 92bac19ad60a..263a2944566f 100644 --- a/drivers/net/cnic.c +++ b/drivers/net/cnic.c | |||
@@ -59,6 +59,7 @@ MODULE_DESCRIPTION("Broadcom NetXtreme II CNIC Driver"); | |||
59 | MODULE_LICENSE("GPL"); | 59 | MODULE_LICENSE("GPL"); |
60 | MODULE_VERSION(CNIC_MODULE_VERSION); | 60 | MODULE_VERSION(CNIC_MODULE_VERSION); |
61 | 61 | ||
62 | /* cnic_dev_list modifications are protected by both rtnl and cnic_dev_lock */ | ||
62 | static LIST_HEAD(cnic_dev_list); | 63 | static LIST_HEAD(cnic_dev_list); |
63 | static LIST_HEAD(cnic_udev_list); | 64 | static LIST_HEAD(cnic_udev_list); |
64 | static DEFINE_RWLOCK(cnic_dev_lock); | 65 | static DEFINE_RWLOCK(cnic_dev_lock); |
@@ -278,6 +279,7 @@ static int cnic_send_nlmsg(struct cnic_local *cp, u32 type, | |||
278 | u32 msg_type = ISCSI_KEVENT_IF_DOWN; | 279 | u32 msg_type = ISCSI_KEVENT_IF_DOWN; |
279 | struct cnic_ulp_ops *ulp_ops; | 280 | struct cnic_ulp_ops *ulp_ops; |
280 | struct cnic_uio_dev *udev = cp->udev; | 281 | struct cnic_uio_dev *udev = cp->udev; |
282 | int rc = 0, retry = 0; | ||
281 | 283 | ||
282 | if (!udev || udev->uio_dev == -1) | 284 | if (!udev || udev->uio_dev == -1) |
283 | return -ENODEV; | 285 | return -ENODEV; |
@@ -302,14 +304,26 @@ static int cnic_send_nlmsg(struct cnic_local *cp, u32 type, | |||
302 | path_req.pmtu = csk->mtu; | 304 | path_req.pmtu = csk->mtu; |
303 | } | 305 | } |
304 | 306 | ||
305 | rcu_read_lock(); | 307 | while (retry < 3) { |
306 | ulp_ops = rcu_dereference(cnic_ulp_tbl[CNIC_ULP_ISCSI]); | 308 | rc = 0; |
307 | if (ulp_ops) | 309 | rcu_read_lock(); |
308 | ulp_ops->iscsi_nl_send_msg(cp->dev, msg_type, buf, len); | 310 | ulp_ops = rcu_dereference(cnic_ulp_tbl[CNIC_ULP_ISCSI]); |
309 | rcu_read_unlock(); | 311 | if (ulp_ops) |
312 | rc = ulp_ops->iscsi_nl_send_msg( | ||
313 | cp->ulp_handle[CNIC_ULP_ISCSI], | ||
314 | msg_type, buf, len); | ||
315 | rcu_read_unlock(); | ||
316 | if (rc == 0 || msg_type != ISCSI_KEVENT_PATH_REQ) | ||
317 | break; | ||
318 | |||
319 | msleep(100); | ||
320 | retry++; | ||
321 | } | ||
310 | return 0; | 322 | return 0; |
311 | } | 323 | } |
312 | 324 | ||
325 | static void cnic_cm_upcall(struct cnic_local *, struct cnic_sock *, u8); | ||
326 | |||
313 | static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type, | 327 | static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type, |
314 | char *buf, u16 len) | 328 | char *buf, u16 len) |
315 | { | 329 | { |
@@ -339,7 +353,9 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type, | |||
339 | } | 353 | } |
340 | csk = &cp->csk_tbl[l5_cid]; | 354 | csk = &cp->csk_tbl[l5_cid]; |
341 | csk_hold(csk); | 355 | csk_hold(csk); |
342 | if (cnic_in_use(csk)) { | 356 | if (cnic_in_use(csk) && |
357 | test_bit(SK_F_CONNECT_START, &csk->flags)) { | ||
358 | |||
343 | memcpy(csk->ha, path_resp->mac_addr, 6); | 359 | memcpy(csk->ha, path_resp->mac_addr, 6); |
344 | if (test_bit(SK_F_IPV6, &csk->flags)) | 360 | if (test_bit(SK_F_IPV6, &csk->flags)) |
345 | memcpy(&csk->src_ip[0], &path_resp->src.v6_addr, | 361 | memcpy(&csk->src_ip[0], &path_resp->src.v6_addr, |
@@ -347,8 +363,16 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type, | |||
347 | else | 363 | else |
348 | memcpy(&csk->src_ip[0], &path_resp->src.v4_addr, | 364 | memcpy(&csk->src_ip[0], &path_resp->src.v4_addr, |
349 | sizeof(struct in_addr)); | 365 | sizeof(struct in_addr)); |
350 | if (is_valid_ether_addr(csk->ha)) | 366 | |
367 | if (is_valid_ether_addr(csk->ha)) { | ||
351 | cnic_cm_set_pg(csk); | 368 | cnic_cm_set_pg(csk); |
369 | } else if (!test_bit(SK_F_OFFLD_SCHED, &csk->flags) && | ||
370 | !test_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) { | ||
371 | |||
372 | cnic_cm_upcall(cp, csk, | ||
373 | L4_KCQE_OPCODE_VALUE_CONNECT_COMPLETE); | ||
374 | clear_bit(SK_F_CONNECT_START, &csk->flags); | ||
375 | } | ||
352 | } | 376 | } |
353 | csk_put(csk); | 377 | csk_put(csk); |
354 | rcu_read_unlock(); | 378 | rcu_read_unlock(); |
@@ -402,19 +426,6 @@ static int cnic_abort_prep(struct cnic_sock *csk) | |||
402 | return 0; | 426 | return 0; |
403 | } | 427 | } |
404 | 428 | ||
405 | static void cnic_uio_stop(void) | ||
406 | { | ||
407 | struct cnic_dev *dev; | ||
408 | |||
409 | read_lock(&cnic_dev_lock); | ||
410 | list_for_each_entry(dev, &cnic_dev_list, list) { | ||
411 | struct cnic_local *cp = dev->cnic_priv; | ||
412 | |||
413 | cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); | ||
414 | } | ||
415 | read_unlock(&cnic_dev_lock); | ||
416 | } | ||
417 | |||
418 | int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops) | 429 | int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops) |
419 | { | 430 | { |
420 | struct cnic_dev *dev; | 431 | struct cnic_dev *dev; |
@@ -445,14 +456,12 @@ int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops) | |||
445 | 456 | ||
446 | /* Prevent race conditions with netdev_event */ | 457 | /* Prevent race conditions with netdev_event */ |
447 | rtnl_lock(); | 458 | rtnl_lock(); |
448 | read_lock(&cnic_dev_lock); | ||
449 | list_for_each_entry(dev, &cnic_dev_list, list) { | 459 | list_for_each_entry(dev, &cnic_dev_list, list) { |
450 | struct cnic_local *cp = dev->cnic_priv; | 460 | struct cnic_local *cp = dev->cnic_priv; |
451 | 461 | ||
452 | if (!test_and_set_bit(ULP_F_INIT, &cp->ulp_flags[ulp_type])) | 462 | if (!test_and_set_bit(ULP_F_INIT, &cp->ulp_flags[ulp_type])) |
453 | ulp_ops->cnic_init(dev); | 463 | ulp_ops->cnic_init(dev); |
454 | } | 464 | } |
455 | read_unlock(&cnic_dev_lock); | ||
456 | rtnl_unlock(); | 465 | rtnl_unlock(); |
457 | 466 | ||
458 | return 0; | 467 | return 0; |
@@ -488,9 +497,6 @@ int cnic_unregister_driver(int ulp_type) | |||
488 | } | 497 | } |
489 | read_unlock(&cnic_dev_lock); | 498 | read_unlock(&cnic_dev_lock); |
490 | 499 | ||
491 | if (ulp_type == CNIC_ULP_ISCSI) | ||
492 | cnic_uio_stop(); | ||
493 | |||
494 | rcu_assign_pointer(cnic_ulp_tbl[ulp_type], NULL); | 500 | rcu_assign_pointer(cnic_ulp_tbl[ulp_type], NULL); |
495 | 501 | ||
496 | mutex_unlock(&cnic_lock); | 502 | mutex_unlock(&cnic_lock); |
@@ -574,6 +580,9 @@ static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type) | |||
574 | } | 580 | } |
575 | mutex_unlock(&cnic_lock); | 581 | mutex_unlock(&cnic_lock); |
576 | 582 | ||
583 | if (ulp_type == CNIC_ULP_ISCSI) | ||
584 | cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); | ||
585 | |||
577 | synchronize_rcu(); | 586 | synchronize_rcu(); |
578 | 587 | ||
579 | while (test_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[ulp_type]) && | 588 | while (test_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[ulp_type]) && |
@@ -821,12 +830,14 @@ static void cnic_free_resc(struct cnic_dev *dev) | |||
821 | cnic_free_dma(dev, &cp->conn_buf_info); | 830 | cnic_free_dma(dev, &cp->conn_buf_info); |
822 | cnic_free_dma(dev, &cp->kwq_info); | 831 | cnic_free_dma(dev, &cp->kwq_info); |
823 | cnic_free_dma(dev, &cp->kwq_16_data_info); | 832 | cnic_free_dma(dev, &cp->kwq_16_data_info); |
833 | cnic_free_dma(dev, &cp->kcq2.dma); | ||
824 | cnic_free_dma(dev, &cp->kcq1.dma); | 834 | cnic_free_dma(dev, &cp->kcq1.dma); |
825 | kfree(cp->iscsi_tbl); | 835 | kfree(cp->iscsi_tbl); |
826 | cp->iscsi_tbl = NULL; | 836 | cp->iscsi_tbl = NULL; |
827 | kfree(cp->ctx_tbl); | 837 | kfree(cp->ctx_tbl); |
828 | cp->ctx_tbl = NULL; | 838 | cp->ctx_tbl = NULL; |
829 | 839 | ||
840 | cnic_free_id_tbl(&cp->fcoe_cid_tbl); | ||
830 | cnic_free_id_tbl(&cp->cid_tbl); | 841 | cnic_free_id_tbl(&cp->cid_tbl); |
831 | } | 842 | } |
832 | 843 | ||
@@ -940,7 +951,7 @@ static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages) | |||
940 | &udev->l2_ring_map, | 951 | &udev->l2_ring_map, |
941 | GFP_KERNEL | __GFP_COMP); | 952 | GFP_KERNEL | __GFP_COMP); |
942 | if (!udev->l2_ring) | 953 | if (!udev->l2_ring) |
943 | return -ENOMEM; | 954 | goto err_udev; |
944 | 955 | ||
945 | udev->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size; | 956 | udev->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size; |
946 | udev->l2_buf_size = PAGE_ALIGN(udev->l2_buf_size); | 957 | udev->l2_buf_size = PAGE_ALIGN(udev->l2_buf_size); |
@@ -948,7 +959,7 @@ static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages) | |||
948 | &udev->l2_buf_map, | 959 | &udev->l2_buf_map, |
949 | GFP_KERNEL | __GFP_COMP); | 960 | GFP_KERNEL | __GFP_COMP); |
950 | if (!udev->l2_buf) | 961 | if (!udev->l2_buf) |
951 | return -ENOMEM; | 962 | goto err_dma; |
952 | 963 | ||
953 | write_lock(&cnic_dev_lock); | 964 | write_lock(&cnic_dev_lock); |
954 | list_add(&udev->list, &cnic_udev_list); | 965 | list_add(&udev->list, &cnic_udev_list); |
@@ -959,6 +970,12 @@ static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages) | |||
959 | cp->udev = udev; | 970 | cp->udev = udev; |
960 | 971 | ||
961 | return 0; | 972 | return 0; |
973 | err_dma: | ||
974 | dma_free_coherent(&udev->pdev->dev, udev->l2_ring_size, | ||
975 | udev->l2_ring, udev->l2_ring_map); | ||
976 | err_udev: | ||
977 | kfree(udev); | ||
978 | return -ENOMEM; | ||
962 | } | 979 | } |
963 | 980 | ||
964 | static int cnic_init_uio(struct cnic_dev *dev) | 981 | static int cnic_init_uio(struct cnic_dev *dev) |
@@ -1114,12 +1131,22 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
1114 | 1131 | ||
1115 | cp->iro_arr = ethdev->iro_arr; | 1132 | cp->iro_arr = ethdev->iro_arr; |
1116 | 1133 | ||
1117 | cp->max_cid_space = MAX_ISCSI_TBL_SZ; | 1134 | cp->max_cid_space = MAX_ISCSI_TBL_SZ + BNX2X_FCOE_NUM_CONNECTIONS; |
1118 | cp->iscsi_start_cid = start_cid; | 1135 | cp->iscsi_start_cid = start_cid; |
1136 | cp->fcoe_start_cid = start_cid + MAX_ISCSI_TBL_SZ; | ||
1137 | |||
1138 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { | ||
1139 | cp->max_cid_space += BNX2X_FCOE_NUM_CONNECTIONS; | ||
1140 | cp->fcoe_init_cid = ethdev->fcoe_init_cid; | ||
1141 | if (!cp->fcoe_init_cid) | ||
1142 | cp->fcoe_init_cid = 0x10; | ||
1143 | } | ||
1144 | |||
1119 | if (start_cid < BNX2X_ISCSI_START_CID) { | 1145 | if (start_cid < BNX2X_ISCSI_START_CID) { |
1120 | u32 delta = BNX2X_ISCSI_START_CID - start_cid; | 1146 | u32 delta = BNX2X_ISCSI_START_CID - start_cid; |
1121 | 1147 | ||
1122 | cp->iscsi_start_cid = BNX2X_ISCSI_START_CID; | 1148 | cp->iscsi_start_cid = BNX2X_ISCSI_START_CID; |
1149 | cp->fcoe_start_cid += delta; | ||
1123 | cp->max_cid_space += delta; | 1150 | cp->max_cid_space += delta; |
1124 | } | 1151 | } |
1125 | 1152 | ||
@@ -1138,6 +1165,9 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
1138 | cp->ctx_tbl[i].ulp_proto_id = CNIC_ULP_ISCSI; | 1165 | cp->ctx_tbl[i].ulp_proto_id = CNIC_ULP_ISCSI; |
1139 | } | 1166 | } |
1140 | 1167 | ||
1168 | for (i = MAX_ISCSI_TBL_SZ; i < cp->max_cid_space; i++) | ||
1169 | cp->ctx_tbl[i].ulp_proto_id = CNIC_ULP_FCOE; | ||
1170 | |||
1141 | pages = PAGE_ALIGN(cp->max_cid_space * CNIC_KWQ16_DATA_SIZE) / | 1171 | pages = PAGE_ALIGN(cp->max_cid_space * CNIC_KWQ16_DATA_SIZE) / |
1142 | PAGE_SIZE; | 1172 | PAGE_SIZE; |
1143 | 1173 | ||
@@ -1161,6 +1191,12 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
1161 | if (ret) | 1191 | if (ret) |
1162 | goto error; | 1192 | goto error; |
1163 | 1193 | ||
1194 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { | ||
1195 | ret = cnic_alloc_kcq(dev, &cp->kcq2); | ||
1196 | if (ret) | ||
1197 | goto error; | ||
1198 | } | ||
1199 | |||
1164 | pages = PAGE_ALIGN(BNX2X_ISCSI_NUM_CONNECTIONS * | 1200 | pages = PAGE_ALIGN(BNX2X_ISCSI_NUM_CONNECTIONS * |
1165 | BNX2X_ISCSI_CONN_BUF_SIZE) / PAGE_SIZE; | 1201 | BNX2X_ISCSI_CONN_BUF_SIZE) / PAGE_SIZE; |
1166 | ret = cnic_alloc_dma(dev, &cp->conn_buf_info, pages, 1); | 1202 | ret = cnic_alloc_dma(dev, &cp->conn_buf_info, pages, 1); |
@@ -1254,12 +1290,18 @@ static int cnic_submit_kwqe_16(struct cnic_dev *dev, u32 cmd, u32 cid, | |||
1254 | struct cnic_local *cp = dev->cnic_priv; | 1290 | struct cnic_local *cp = dev->cnic_priv; |
1255 | struct l5cm_spe kwqe; | 1291 | struct l5cm_spe kwqe; |
1256 | struct kwqe_16 *kwq[1]; | 1292 | struct kwqe_16 *kwq[1]; |
1293 | u16 type_16; | ||
1257 | int ret; | 1294 | int ret; |
1258 | 1295 | ||
1259 | kwqe.hdr.conn_and_cmd_data = | 1296 | kwqe.hdr.conn_and_cmd_data = |
1260 | cpu_to_le32(((cmd << SPE_HDR_CMD_ID_SHIFT) | | 1297 | cpu_to_le32(((cmd << SPE_HDR_CMD_ID_SHIFT) | |
1261 | BNX2X_HW_CID(cp, cid))); | 1298 | BNX2X_HW_CID(cp, cid))); |
1262 | kwqe.hdr.type = cpu_to_le16(type); | 1299 | |
1300 | type_16 = (type << SPE_HDR_CONN_TYPE_SHIFT) & SPE_HDR_CONN_TYPE; | ||
1301 | type_16 |= (cp->pfid << SPE_HDR_FUNCTION_ID_SHIFT) & | ||
1302 | SPE_HDR_FUNCTION_ID; | ||
1303 | |||
1304 | kwqe.hdr.type = cpu_to_le16(type_16); | ||
1263 | kwqe.hdr.reserved1 = 0; | 1305 | kwqe.hdr.reserved1 = 0; |
1264 | kwqe.data.phy_address.lo = cpu_to_le32(l5_data->phy_address.lo); | 1306 | kwqe.data.phy_address.lo = cpu_to_le32(l5_data->phy_address.lo); |
1265 | kwqe.data.phy_address.hi = cpu_to_le32(l5_data->phy_address.hi); | 1307 | kwqe.data.phy_address.hi = cpu_to_le32(l5_data->phy_address.hi); |
@@ -1425,8 +1467,11 @@ static void cnic_free_bnx2x_conn_resc(struct cnic_dev *dev, u32 l5_cid) | |||
1425 | cnic_free_dma(dev, &iscsi->hq_info); | 1467 | cnic_free_dma(dev, &iscsi->hq_info); |
1426 | cnic_free_dma(dev, &iscsi->r2tq_info); | 1468 | cnic_free_dma(dev, &iscsi->r2tq_info); |
1427 | cnic_free_dma(dev, &iscsi->task_array_info); | 1469 | cnic_free_dma(dev, &iscsi->task_array_info); |
1470 | cnic_free_id(&cp->cid_tbl, ctx->cid); | ||
1471 | } else { | ||
1472 | cnic_free_id(&cp->fcoe_cid_tbl, ctx->cid); | ||
1428 | } | 1473 | } |
1429 | cnic_free_id(&cp->cid_tbl, ctx->cid); | 1474 | |
1430 | ctx->cid = 0; | 1475 | ctx->cid = 0; |
1431 | } | 1476 | } |
1432 | 1477 | ||
@@ -1438,6 +1483,16 @@ static int cnic_alloc_bnx2x_conn_resc(struct cnic_dev *dev, u32 l5_cid) | |||
1438 | struct cnic_context *ctx = &cp->ctx_tbl[l5_cid]; | 1483 | struct cnic_context *ctx = &cp->ctx_tbl[l5_cid]; |
1439 | struct cnic_iscsi *iscsi = ctx->proto.iscsi; | 1484 | struct cnic_iscsi *iscsi = ctx->proto.iscsi; |
1440 | 1485 | ||
1486 | if (ctx->ulp_proto_id == CNIC_ULP_FCOE) { | ||
1487 | cid = cnic_alloc_new_id(&cp->fcoe_cid_tbl); | ||
1488 | if (cid == -1) { | ||
1489 | ret = -ENOMEM; | ||
1490 | goto error; | ||
1491 | } | ||
1492 | ctx->cid = cid; | ||
1493 | return 0; | ||
1494 | } | ||
1495 | |||
1441 | cid = cnic_alloc_new_id(&cp->cid_tbl); | 1496 | cid = cnic_alloc_new_id(&cp->cid_tbl); |
1442 | if (cid == -1) { | 1497 | if (cid == -1) { |
1443 | ret = -ENOMEM; | 1498 | ret = -ENOMEM; |
@@ -1695,7 +1750,7 @@ static int cnic_bnx2x_iscsi_ofld1(struct cnic_dev *dev, struct kwqe *wqes[], | |||
1695 | *work = num; | 1750 | *work = num; |
1696 | return -EINVAL; | 1751 | return -EINVAL; |
1697 | } | 1752 | } |
1698 | *work = 2 + req2->num_additional_wqes;; | 1753 | *work = 2 + req2->num_additional_wqes; |
1699 | 1754 | ||
1700 | l5_cid = req1->iscsi_conn_id; | 1755 | l5_cid = req1->iscsi_conn_id; |
1701 | if (l5_cid >= MAX_ISCSI_TBL_SZ) | 1756 | if (l5_cid >= MAX_ISCSI_TBL_SZ) |
@@ -1770,19 +1825,15 @@ static int cnic_bnx2x_destroy_ramrod(struct cnic_dev *dev, u32 l5_cid) | |||
1770 | struct cnic_context *ctx = &cp->ctx_tbl[l5_cid]; | 1825 | struct cnic_context *ctx = &cp->ctx_tbl[l5_cid]; |
1771 | union l5cm_specific_data l5_data; | 1826 | union l5cm_specific_data l5_data; |
1772 | int ret; | 1827 | int ret; |
1773 | u32 hw_cid, type; | 1828 | u32 hw_cid; |
1774 | 1829 | ||
1775 | init_waitqueue_head(&ctx->waitq); | 1830 | init_waitqueue_head(&ctx->waitq); |
1776 | ctx->wait_cond = 0; | 1831 | ctx->wait_cond = 0; |
1777 | memset(&l5_data, 0, sizeof(l5_data)); | 1832 | memset(&l5_data, 0, sizeof(l5_data)); |
1778 | hw_cid = BNX2X_HW_CID(cp, ctx->cid); | 1833 | hw_cid = BNX2X_HW_CID(cp, ctx->cid); |
1779 | type = (NONE_CONNECTION_TYPE << SPE_HDR_CONN_TYPE_SHIFT) | ||
1780 | & SPE_HDR_CONN_TYPE; | ||
1781 | type |= ((cp->pfid << SPE_HDR_FUNCTION_ID_SHIFT) & | ||
1782 | SPE_HDR_FUNCTION_ID); | ||
1783 | 1834 | ||
1784 | ret = cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_COMMON_CFC_DEL, | 1835 | ret = cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_COMMON_CFC_DEL, |
1785 | hw_cid, type, &l5_data); | 1836 | hw_cid, NONE_CONNECTION_TYPE, &l5_data); |
1786 | 1837 | ||
1787 | if (ret == 0) | 1838 | if (ret == 0) |
1788 | wait_event(ctx->waitq, ctx->wait_cond); | 1839 | wait_event(ctx->waitq, ctx->wait_cond); |
@@ -2078,8 +2129,306 @@ static int cnic_bnx2x_update_pg(struct cnic_dev *dev, struct kwqe *kwqe) | |||
2078 | return 0; | 2129 | return 0; |
2079 | } | 2130 | } |
2080 | 2131 | ||
2081 | static int cnic_submit_bnx2x_kwqes(struct cnic_dev *dev, struct kwqe *wqes[], | 2132 | static int cnic_bnx2x_fcoe_stat(struct cnic_dev *dev, struct kwqe *kwqe) |
2082 | u32 num_wqes) | 2133 | { |
2134 | struct fcoe_kwqe_stat *req; | ||
2135 | struct fcoe_stat_ramrod_params *fcoe_stat; | ||
2136 | union l5cm_specific_data l5_data; | ||
2137 | struct cnic_local *cp = dev->cnic_priv; | ||
2138 | int ret; | ||
2139 | u32 cid; | ||
2140 | |||
2141 | req = (struct fcoe_kwqe_stat *) kwqe; | ||
2142 | cid = BNX2X_HW_CID(cp, cp->fcoe_init_cid); | ||
2143 | |||
2144 | fcoe_stat = cnic_get_kwqe_16_data(cp, BNX2X_FCOE_L5_CID_BASE, &l5_data); | ||
2145 | if (!fcoe_stat) | ||
2146 | return -ENOMEM; | ||
2147 | |||
2148 | memset(fcoe_stat, 0, sizeof(*fcoe_stat)); | ||
2149 | memcpy(&fcoe_stat->stat_kwqe, req, sizeof(*req)); | ||
2150 | |||
2151 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_STAT, cid, | ||
2152 | FCOE_CONNECTION_TYPE, &l5_data); | ||
2153 | return ret; | ||
2154 | } | ||
2155 | |||
2156 | static int cnic_bnx2x_fcoe_init1(struct cnic_dev *dev, struct kwqe *wqes[], | ||
2157 | u32 num, int *work) | ||
2158 | { | ||
2159 | int ret; | ||
2160 | struct cnic_local *cp = dev->cnic_priv; | ||
2161 | u32 cid; | ||
2162 | struct fcoe_init_ramrod_params *fcoe_init; | ||
2163 | struct fcoe_kwqe_init1 *req1; | ||
2164 | struct fcoe_kwqe_init2 *req2; | ||
2165 | struct fcoe_kwqe_init3 *req3; | ||
2166 | union l5cm_specific_data l5_data; | ||
2167 | |||
2168 | if (num < 3) { | ||
2169 | *work = num; | ||
2170 | return -EINVAL; | ||
2171 | } | ||
2172 | req1 = (struct fcoe_kwqe_init1 *) wqes[0]; | ||
2173 | req2 = (struct fcoe_kwqe_init2 *) wqes[1]; | ||
2174 | req3 = (struct fcoe_kwqe_init3 *) wqes[2]; | ||
2175 | if (req2->hdr.op_code != FCOE_KWQE_OPCODE_INIT2) { | ||
2176 | *work = 1; | ||
2177 | return -EINVAL; | ||
2178 | } | ||
2179 | if (req3->hdr.op_code != FCOE_KWQE_OPCODE_INIT3) { | ||
2180 | *work = 2; | ||
2181 | return -EINVAL; | ||
2182 | } | ||
2183 | |||
2184 | if (sizeof(*fcoe_init) > CNIC_KWQ16_DATA_SIZE) { | ||
2185 | netdev_err(dev->netdev, "fcoe_init size too big\n"); | ||
2186 | return -ENOMEM; | ||
2187 | } | ||
2188 | fcoe_init = cnic_get_kwqe_16_data(cp, BNX2X_FCOE_L5_CID_BASE, &l5_data); | ||
2189 | if (!fcoe_init) | ||
2190 | return -ENOMEM; | ||
2191 | |||
2192 | memset(fcoe_init, 0, sizeof(*fcoe_init)); | ||
2193 | memcpy(&fcoe_init->init_kwqe1, req1, sizeof(*req1)); | ||
2194 | memcpy(&fcoe_init->init_kwqe2, req2, sizeof(*req2)); | ||
2195 | memcpy(&fcoe_init->init_kwqe3, req3, sizeof(*req3)); | ||
2196 | fcoe_init->eq_addr.lo = cp->kcq2.dma.pg_map_arr[0] & 0xffffffff; | ||
2197 | fcoe_init->eq_addr.hi = (u64) cp->kcq2.dma.pg_map_arr[0] >> 32; | ||
2198 | fcoe_init->eq_next_page_addr.lo = | ||
2199 | cp->kcq2.dma.pg_map_arr[1] & 0xffffffff; | ||
2200 | fcoe_init->eq_next_page_addr.hi = | ||
2201 | (u64) cp->kcq2.dma.pg_map_arr[1] >> 32; | ||
2202 | |||
2203 | fcoe_init->sb_num = cp->status_blk_num; | ||
2204 | fcoe_init->eq_prod = MAX_KCQ_IDX; | ||
2205 | fcoe_init->sb_id = HC_INDEX_FCOE_EQ_CONS; | ||
2206 | cp->kcq2.sw_prod_idx = 0; | ||
2207 | |||
2208 | cid = BNX2X_HW_CID(cp, cp->fcoe_init_cid); | ||
2209 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_INIT, cid, | ||
2210 | FCOE_CONNECTION_TYPE, &l5_data); | ||
2211 | *work = 3; | ||
2212 | return ret; | ||
2213 | } | ||
2214 | |||
2215 | static int cnic_bnx2x_fcoe_ofld1(struct cnic_dev *dev, struct kwqe *wqes[], | ||
2216 | u32 num, int *work) | ||
2217 | { | ||
2218 | int ret = 0; | ||
2219 | u32 cid = -1, l5_cid; | ||
2220 | struct cnic_local *cp = dev->cnic_priv; | ||
2221 | struct fcoe_kwqe_conn_offload1 *req1; | ||
2222 | struct fcoe_kwqe_conn_offload2 *req2; | ||
2223 | struct fcoe_kwqe_conn_offload3 *req3; | ||
2224 | struct fcoe_kwqe_conn_offload4 *req4; | ||
2225 | struct fcoe_conn_offload_ramrod_params *fcoe_offload; | ||
2226 | struct cnic_context *ctx; | ||
2227 | struct fcoe_context *fctx; | ||
2228 | struct regpair ctx_addr; | ||
2229 | union l5cm_specific_data l5_data; | ||
2230 | struct fcoe_kcqe kcqe; | ||
2231 | struct kcqe *cqes[1]; | ||
2232 | |||
2233 | if (num < 4) { | ||
2234 | *work = num; | ||
2235 | return -EINVAL; | ||
2236 | } | ||
2237 | req1 = (struct fcoe_kwqe_conn_offload1 *) wqes[0]; | ||
2238 | req2 = (struct fcoe_kwqe_conn_offload2 *) wqes[1]; | ||
2239 | req3 = (struct fcoe_kwqe_conn_offload3 *) wqes[2]; | ||
2240 | req4 = (struct fcoe_kwqe_conn_offload4 *) wqes[3]; | ||
2241 | |||
2242 | *work = 4; | ||
2243 | |||
2244 | l5_cid = req1->fcoe_conn_id; | ||
2245 | if (l5_cid >= BNX2X_FCOE_NUM_CONNECTIONS) | ||
2246 | goto err_reply; | ||
2247 | |||
2248 | l5_cid += BNX2X_FCOE_L5_CID_BASE; | ||
2249 | |||
2250 | ctx = &cp->ctx_tbl[l5_cid]; | ||
2251 | if (test_bit(CTX_FL_OFFLD_START, &ctx->ctx_flags)) | ||
2252 | goto err_reply; | ||
2253 | |||
2254 | ret = cnic_alloc_bnx2x_conn_resc(dev, l5_cid); | ||
2255 | if (ret) { | ||
2256 | ret = 0; | ||
2257 | goto err_reply; | ||
2258 | } | ||
2259 | cid = ctx->cid; | ||
2260 | |||
2261 | fctx = cnic_get_bnx2x_ctx(dev, cid, 1, &ctx_addr); | ||
2262 | if (fctx) { | ||
2263 | u32 hw_cid = BNX2X_HW_CID(cp, cid); | ||
2264 | u32 val; | ||
2265 | |||
2266 | val = CDU_RSRVD_VALUE_TYPE_A(hw_cid, CDU_REGION_NUMBER_XCM_AG, | ||
2267 | FCOE_CONNECTION_TYPE); | ||
2268 | fctx->xstorm_ag_context.cdu_reserved = val; | ||
2269 | val = CDU_RSRVD_VALUE_TYPE_A(hw_cid, CDU_REGION_NUMBER_UCM_AG, | ||
2270 | FCOE_CONNECTION_TYPE); | ||
2271 | fctx->ustorm_ag_context.cdu_usage = val; | ||
2272 | } | ||
2273 | if (sizeof(*fcoe_offload) > CNIC_KWQ16_DATA_SIZE) { | ||
2274 | netdev_err(dev->netdev, "fcoe_offload size too big\n"); | ||
2275 | goto err_reply; | ||
2276 | } | ||
2277 | fcoe_offload = cnic_get_kwqe_16_data(cp, l5_cid, &l5_data); | ||
2278 | if (!fcoe_offload) | ||
2279 | goto err_reply; | ||
2280 | |||
2281 | memset(fcoe_offload, 0, sizeof(*fcoe_offload)); | ||
2282 | memcpy(&fcoe_offload->offload_kwqe1, req1, sizeof(*req1)); | ||
2283 | memcpy(&fcoe_offload->offload_kwqe2, req2, sizeof(*req2)); | ||
2284 | memcpy(&fcoe_offload->offload_kwqe3, req3, sizeof(*req3)); | ||
2285 | memcpy(&fcoe_offload->offload_kwqe4, req4, sizeof(*req4)); | ||
2286 | |||
2287 | cid = BNX2X_HW_CID(cp, cid); | ||
2288 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_OFFLOAD_CONN, cid, | ||
2289 | FCOE_CONNECTION_TYPE, &l5_data); | ||
2290 | if (!ret) | ||
2291 | set_bit(CTX_FL_OFFLD_START, &ctx->ctx_flags); | ||
2292 | |||
2293 | return ret; | ||
2294 | |||
2295 | err_reply: | ||
2296 | if (cid != -1) | ||
2297 | cnic_free_bnx2x_conn_resc(dev, l5_cid); | ||
2298 | |||
2299 | memset(&kcqe, 0, sizeof(kcqe)); | ||
2300 | kcqe.op_code = FCOE_KCQE_OPCODE_OFFLOAD_CONN; | ||
2301 | kcqe.fcoe_conn_id = req1->fcoe_conn_id; | ||
2302 | kcqe.completion_status = FCOE_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAILURE; | ||
2303 | |||
2304 | cqes[0] = (struct kcqe *) &kcqe; | ||
2305 | cnic_reply_bnx2x_kcqes(dev, CNIC_ULP_FCOE, cqes, 1); | ||
2306 | return ret; | ||
2307 | } | ||
2308 | |||
2309 | static int cnic_bnx2x_fcoe_enable(struct cnic_dev *dev, struct kwqe *kwqe) | ||
2310 | { | ||
2311 | struct fcoe_kwqe_conn_enable_disable *req; | ||
2312 | struct fcoe_conn_enable_disable_ramrod_params *fcoe_enable; | ||
2313 | union l5cm_specific_data l5_data; | ||
2314 | int ret; | ||
2315 | u32 cid, l5_cid; | ||
2316 | struct cnic_local *cp = dev->cnic_priv; | ||
2317 | |||
2318 | req = (struct fcoe_kwqe_conn_enable_disable *) kwqe; | ||
2319 | cid = req->context_id; | ||
2320 | l5_cid = req->conn_id + BNX2X_FCOE_L5_CID_BASE; | ||
2321 | |||
2322 | if (sizeof(*fcoe_enable) > CNIC_KWQ16_DATA_SIZE) { | ||
2323 | netdev_err(dev->netdev, "fcoe_enable size too big\n"); | ||
2324 | return -ENOMEM; | ||
2325 | } | ||
2326 | fcoe_enable = cnic_get_kwqe_16_data(cp, l5_cid, &l5_data); | ||
2327 | if (!fcoe_enable) | ||
2328 | return -ENOMEM; | ||
2329 | |||
2330 | memset(fcoe_enable, 0, sizeof(*fcoe_enable)); | ||
2331 | memcpy(&fcoe_enable->enable_disable_kwqe, req, sizeof(*req)); | ||
2332 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_ENABLE_CONN, cid, | ||
2333 | FCOE_CONNECTION_TYPE, &l5_data); | ||
2334 | return ret; | ||
2335 | } | ||
2336 | |||
2337 | static int cnic_bnx2x_fcoe_disable(struct cnic_dev *dev, struct kwqe *kwqe) | ||
2338 | { | ||
2339 | struct fcoe_kwqe_conn_enable_disable *req; | ||
2340 | struct fcoe_conn_enable_disable_ramrod_params *fcoe_disable; | ||
2341 | union l5cm_specific_data l5_data; | ||
2342 | int ret; | ||
2343 | u32 cid, l5_cid; | ||
2344 | struct cnic_local *cp = dev->cnic_priv; | ||
2345 | |||
2346 | req = (struct fcoe_kwqe_conn_enable_disable *) kwqe; | ||
2347 | cid = req->context_id; | ||
2348 | l5_cid = req->conn_id; | ||
2349 | if (l5_cid >= BNX2X_FCOE_NUM_CONNECTIONS) | ||
2350 | return -EINVAL; | ||
2351 | |||
2352 | l5_cid += BNX2X_FCOE_L5_CID_BASE; | ||
2353 | |||
2354 | if (sizeof(*fcoe_disable) > CNIC_KWQ16_DATA_SIZE) { | ||
2355 | netdev_err(dev->netdev, "fcoe_disable size too big\n"); | ||
2356 | return -ENOMEM; | ||
2357 | } | ||
2358 | fcoe_disable = cnic_get_kwqe_16_data(cp, l5_cid, &l5_data); | ||
2359 | if (!fcoe_disable) | ||
2360 | return -ENOMEM; | ||
2361 | |||
2362 | memset(fcoe_disable, 0, sizeof(*fcoe_disable)); | ||
2363 | memcpy(&fcoe_disable->enable_disable_kwqe, req, sizeof(*req)); | ||
2364 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_DISABLE_CONN, cid, | ||
2365 | FCOE_CONNECTION_TYPE, &l5_data); | ||
2366 | return ret; | ||
2367 | } | ||
2368 | |||
2369 | static int cnic_bnx2x_fcoe_destroy(struct cnic_dev *dev, struct kwqe *kwqe) | ||
2370 | { | ||
2371 | struct fcoe_kwqe_conn_destroy *req; | ||
2372 | union l5cm_specific_data l5_data; | ||
2373 | int ret; | ||
2374 | u32 cid, l5_cid; | ||
2375 | struct cnic_local *cp = dev->cnic_priv; | ||
2376 | struct cnic_context *ctx; | ||
2377 | struct fcoe_kcqe kcqe; | ||
2378 | struct kcqe *cqes[1]; | ||
2379 | |||
2380 | req = (struct fcoe_kwqe_conn_destroy *) kwqe; | ||
2381 | cid = req->context_id; | ||
2382 | l5_cid = req->conn_id; | ||
2383 | if (l5_cid >= BNX2X_FCOE_NUM_CONNECTIONS) | ||
2384 | return -EINVAL; | ||
2385 | |||
2386 | l5_cid += BNX2X_FCOE_L5_CID_BASE; | ||
2387 | |||
2388 | ctx = &cp->ctx_tbl[l5_cid]; | ||
2389 | |||
2390 | init_waitqueue_head(&ctx->waitq); | ||
2391 | ctx->wait_cond = 0; | ||
2392 | |||
2393 | memset(&l5_data, 0, sizeof(l5_data)); | ||
2394 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_TERMINATE_CONN, cid, | ||
2395 | FCOE_CONNECTION_TYPE, &l5_data); | ||
2396 | if (ret == 0) { | ||
2397 | wait_event(ctx->waitq, ctx->wait_cond); | ||
2398 | set_bit(CTX_FL_DELETE_WAIT, &ctx->ctx_flags); | ||
2399 | queue_delayed_work(cnic_wq, &cp->delete_task, | ||
2400 | msecs_to_jiffies(2000)); | ||
2401 | } | ||
2402 | |||
2403 | memset(&kcqe, 0, sizeof(kcqe)); | ||
2404 | kcqe.op_code = FCOE_KCQE_OPCODE_DESTROY_CONN; | ||
2405 | kcqe.fcoe_conn_id = req->conn_id; | ||
2406 | kcqe.fcoe_conn_context_id = cid; | ||
2407 | |||
2408 | cqes[0] = (struct kcqe *) &kcqe; | ||
2409 | cnic_reply_bnx2x_kcqes(dev, CNIC_ULP_FCOE, cqes, 1); | ||
2410 | return ret; | ||
2411 | } | ||
2412 | |||
2413 | static int cnic_bnx2x_fcoe_fw_destroy(struct cnic_dev *dev, struct kwqe *kwqe) | ||
2414 | { | ||
2415 | struct fcoe_kwqe_destroy *req; | ||
2416 | union l5cm_specific_data l5_data; | ||
2417 | struct cnic_local *cp = dev->cnic_priv; | ||
2418 | int ret; | ||
2419 | u32 cid; | ||
2420 | |||
2421 | req = (struct fcoe_kwqe_destroy *) kwqe; | ||
2422 | cid = BNX2X_HW_CID(cp, cp->fcoe_init_cid); | ||
2423 | |||
2424 | memset(&l5_data, 0, sizeof(l5_data)); | ||
2425 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_DESTROY, cid, | ||
2426 | FCOE_CONNECTION_TYPE, &l5_data); | ||
2427 | return ret; | ||
2428 | } | ||
2429 | |||
2430 | static int cnic_submit_bnx2x_iscsi_kwqes(struct cnic_dev *dev, | ||
2431 | struct kwqe *wqes[], u32 num_wqes) | ||
2083 | { | 2432 | { |
2084 | int i, work, ret; | 2433 | int i, work, ret; |
2085 | u32 opcode; | 2434 | u32 opcode; |
@@ -2143,6 +2492,98 @@ static int cnic_submit_bnx2x_kwqes(struct cnic_dev *dev, struct kwqe *wqes[], | |||
2143 | return 0; | 2492 | return 0; |
2144 | } | 2493 | } |
2145 | 2494 | ||
2495 | static int cnic_submit_bnx2x_fcoe_kwqes(struct cnic_dev *dev, | ||
2496 | struct kwqe *wqes[], u32 num_wqes) | ||
2497 | { | ||
2498 | struct cnic_local *cp = dev->cnic_priv; | ||
2499 | int i, work, ret; | ||
2500 | u32 opcode; | ||
2501 | struct kwqe *kwqe; | ||
2502 | |||
2503 | if (!test_bit(CNIC_F_CNIC_UP, &dev->flags)) | ||
2504 | return -EAGAIN; /* bnx2 is down */ | ||
2505 | |||
2506 | if (BNX2X_CHIP_NUM(cp->chip_id) == BNX2X_CHIP_NUM_57710) | ||
2507 | return -EINVAL; | ||
2508 | |||
2509 | for (i = 0; i < num_wqes; ) { | ||
2510 | kwqe = wqes[i]; | ||
2511 | opcode = KWQE_OPCODE(kwqe->kwqe_op_flag); | ||
2512 | work = 1; | ||
2513 | |||
2514 | switch (opcode) { | ||
2515 | case FCOE_KWQE_OPCODE_INIT1: | ||
2516 | ret = cnic_bnx2x_fcoe_init1(dev, &wqes[i], | ||
2517 | num_wqes - i, &work); | ||
2518 | break; | ||
2519 | case FCOE_KWQE_OPCODE_OFFLOAD_CONN1: | ||
2520 | ret = cnic_bnx2x_fcoe_ofld1(dev, &wqes[i], | ||
2521 | num_wqes - i, &work); | ||
2522 | break; | ||
2523 | case FCOE_KWQE_OPCODE_ENABLE_CONN: | ||
2524 | ret = cnic_bnx2x_fcoe_enable(dev, kwqe); | ||
2525 | break; | ||
2526 | case FCOE_KWQE_OPCODE_DISABLE_CONN: | ||
2527 | ret = cnic_bnx2x_fcoe_disable(dev, kwqe); | ||
2528 | break; | ||
2529 | case FCOE_KWQE_OPCODE_DESTROY_CONN: | ||
2530 | ret = cnic_bnx2x_fcoe_destroy(dev, kwqe); | ||
2531 | break; | ||
2532 | case FCOE_KWQE_OPCODE_DESTROY: | ||
2533 | ret = cnic_bnx2x_fcoe_fw_destroy(dev, kwqe); | ||
2534 | break; | ||
2535 | case FCOE_KWQE_OPCODE_STAT: | ||
2536 | ret = cnic_bnx2x_fcoe_stat(dev, kwqe); | ||
2537 | break; | ||
2538 | default: | ||
2539 | ret = 0; | ||
2540 | netdev_err(dev->netdev, "Unknown type of KWQE(0x%x)\n", | ||
2541 | opcode); | ||
2542 | break; | ||
2543 | } | ||
2544 | if (ret < 0) | ||
2545 | netdev_err(dev->netdev, "KWQE(0x%x) failed\n", | ||
2546 | opcode); | ||
2547 | i += work; | ||
2548 | } | ||
2549 | return 0; | ||
2550 | } | ||
2551 | |||
2552 | static int cnic_submit_bnx2x_kwqes(struct cnic_dev *dev, struct kwqe *wqes[], | ||
2553 | u32 num_wqes) | ||
2554 | { | ||
2555 | int ret = -EINVAL; | ||
2556 | u32 layer_code; | ||
2557 | |||
2558 | if (!test_bit(CNIC_F_CNIC_UP, &dev->flags)) | ||
2559 | return -EAGAIN; /* bnx2x is down */ | ||
2560 | |||
2561 | if (!num_wqes) | ||
2562 | return 0; | ||
2563 | |||
2564 | layer_code = wqes[0]->kwqe_op_flag & KWQE_LAYER_MASK; | ||
2565 | switch (layer_code) { | ||
2566 | case KWQE_FLAGS_LAYER_MASK_L5_ISCSI: | ||
2567 | case KWQE_FLAGS_LAYER_MASK_L4: | ||
2568 | case KWQE_FLAGS_LAYER_MASK_L2: | ||
2569 | ret = cnic_submit_bnx2x_iscsi_kwqes(dev, wqes, num_wqes); | ||
2570 | break; | ||
2571 | |||
2572 | case KWQE_FLAGS_LAYER_MASK_L5_FCOE: | ||
2573 | ret = cnic_submit_bnx2x_fcoe_kwqes(dev, wqes, num_wqes); | ||
2574 | break; | ||
2575 | } | ||
2576 | return ret; | ||
2577 | } | ||
2578 | |||
2579 | static inline u32 cnic_get_kcqe_layer_mask(u32 opflag) | ||
2580 | { | ||
2581 | if (unlikely(KCQE_OPCODE(opflag) == FCOE_RAMROD_CMD_ID_TERMINATE_CONN)) | ||
2582 | return KCQE_FLAGS_LAYER_MASK_L4; | ||
2583 | |||
2584 | return opflag & KCQE_FLAGS_LAYER_MASK; | ||
2585 | } | ||
2586 | |||
2146 | static void service_kcqes(struct cnic_dev *dev, int num_cqes) | 2587 | static void service_kcqes(struct cnic_dev *dev, int num_cqes) |
2147 | { | 2588 | { |
2148 | struct cnic_local *cp = dev->cnic_priv; | 2589 | struct cnic_local *cp = dev->cnic_priv; |
@@ -2154,7 +2595,7 @@ static void service_kcqes(struct cnic_dev *dev, int num_cqes) | |||
2154 | struct cnic_ulp_ops *ulp_ops; | 2595 | struct cnic_ulp_ops *ulp_ops; |
2155 | int ulp_type; | 2596 | int ulp_type; |
2156 | u32 kcqe_op_flag = cp->completed_kcq[i]->kcqe_op_flag; | 2597 | u32 kcqe_op_flag = cp->completed_kcq[i]->kcqe_op_flag; |
2157 | u32 kcqe_layer = kcqe_op_flag & KCQE_FLAGS_LAYER_MASK; | 2598 | u32 kcqe_layer = cnic_get_kcqe_layer_mask(kcqe_op_flag); |
2158 | 2599 | ||
2159 | if (unlikely(kcqe_op_flag & KCQE_RAMROD_COMPLETION)) | 2600 | if (unlikely(kcqe_op_flag & KCQE_RAMROD_COMPLETION)) |
2160 | comp++; | 2601 | comp++; |
@@ -2162,7 +2603,7 @@ static void service_kcqes(struct cnic_dev *dev, int num_cqes) | |||
2162 | while (j < num_cqes) { | 2603 | while (j < num_cqes) { |
2163 | u32 next_op = cp->completed_kcq[i + j]->kcqe_op_flag; | 2604 | u32 next_op = cp->completed_kcq[i + j]->kcqe_op_flag; |
2164 | 2605 | ||
2165 | if ((next_op & KCQE_FLAGS_LAYER_MASK) != kcqe_layer) | 2606 | if (cnic_get_kcqe_layer_mask(next_op) != kcqe_layer) |
2166 | break; | 2607 | break; |
2167 | 2608 | ||
2168 | if (unlikely(next_op & KCQE_RAMROD_COMPLETION)) | 2609 | if (unlikely(next_op & KCQE_RAMROD_COMPLETION)) |
@@ -2174,6 +2615,8 @@ static void service_kcqes(struct cnic_dev *dev, int num_cqes) | |||
2174 | ulp_type = CNIC_ULP_RDMA; | 2615 | ulp_type = CNIC_ULP_RDMA; |
2175 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L5_ISCSI) | 2616 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L5_ISCSI) |
2176 | ulp_type = CNIC_ULP_ISCSI; | 2617 | ulp_type = CNIC_ULP_ISCSI; |
2618 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L5_FCOE) | ||
2619 | ulp_type = CNIC_ULP_FCOE; | ||
2177 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L4) | 2620 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L4) |
2178 | ulp_type = CNIC_ULP_L4; | 2621 | ulp_type = CNIC_ULP_L4; |
2179 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L2) | 2622 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L2) |
@@ -2342,11 +2785,12 @@ static u32 cnic_service_bnx2_queues(struct cnic_dev *dev) | |||
2342 | static int cnic_service_bnx2(void *data, void *status_blk) | 2785 | static int cnic_service_bnx2(void *data, void *status_blk) |
2343 | { | 2786 | { |
2344 | struct cnic_dev *dev = data; | 2787 | struct cnic_dev *dev = data; |
2345 | struct cnic_local *cp = dev->cnic_priv; | ||
2346 | u32 status_idx = *cp->kcq1.status_idx_ptr; | ||
2347 | 2788 | ||
2348 | if (unlikely(!test_bit(CNIC_F_CNIC_UP, &dev->flags))) | 2789 | if (unlikely(!test_bit(CNIC_F_CNIC_UP, &dev->flags))) { |
2349 | return status_idx; | 2790 | struct status_block *sblk = status_blk; |
2791 | |||
2792 | return sblk->status_idx; | ||
2793 | } | ||
2350 | 2794 | ||
2351 | return cnic_service_bnx2_queues(dev); | 2795 | return cnic_service_bnx2_queues(dev); |
2352 | } | 2796 | } |
@@ -2365,9 +2809,10 @@ static void cnic_service_bnx2_msix(unsigned long data) | |||
2365 | static void cnic_doirq(struct cnic_dev *dev) | 2809 | static void cnic_doirq(struct cnic_dev *dev) |
2366 | { | 2810 | { |
2367 | struct cnic_local *cp = dev->cnic_priv; | 2811 | struct cnic_local *cp = dev->cnic_priv; |
2368 | u16 prod = cp->kcq1.sw_prod_idx & MAX_KCQ_IDX; | ||
2369 | 2812 | ||
2370 | if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags))) { | 2813 | if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags))) { |
2814 | u16 prod = cp->kcq1.sw_prod_idx & MAX_KCQ_IDX; | ||
2815 | |||
2371 | prefetch(cp->status_blk.gen); | 2816 | prefetch(cp->status_blk.gen); |
2372 | prefetch(&cp->kcq1.kcq[KCQ_PG(prod)][KCQ_IDX(prod)]); | 2817 | prefetch(&cp->kcq1.kcq[KCQ_PG(prod)][KCQ_IDX(prod)]); |
2373 | 2818 | ||
@@ -2469,12 +2914,19 @@ static void cnic_service_bnx2x_bh(unsigned long data) | |||
2469 | status_idx = cnic_service_bnx2x_kcq(dev, &cp->kcq1); | 2914 | status_idx = cnic_service_bnx2x_kcq(dev, &cp->kcq1); |
2470 | 2915 | ||
2471 | CNIC_WR16(dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx + MAX_KCQ_IDX); | 2916 | CNIC_WR16(dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx + MAX_KCQ_IDX); |
2472 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) | 2917 | |
2918 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { | ||
2919 | status_idx = cnic_service_bnx2x_kcq(dev, &cp->kcq2); | ||
2920 | |||
2921 | CNIC_WR16(dev, cp->kcq2.io_addr, cp->kcq2.sw_prod_idx + | ||
2922 | MAX_KCQ_IDX); | ||
2923 | |||
2473 | cnic_ack_igu_sb(dev, cp->bnx2x_igu_sb_id, IGU_SEG_ACCESS_DEF, | 2924 | cnic_ack_igu_sb(dev, cp->bnx2x_igu_sb_id, IGU_SEG_ACCESS_DEF, |
2474 | status_idx, IGU_INT_ENABLE, 1); | 2925 | status_idx, IGU_INT_ENABLE, 1); |
2475 | else | 2926 | } else { |
2476 | cnic_ack_bnx2x_int(dev, cp->bnx2x_igu_sb_id, USTORM_ID, | 2927 | cnic_ack_bnx2x_int(dev, cp->bnx2x_igu_sb_id, USTORM_ID, |
2477 | status_idx, IGU_INT_ENABLE, 1); | 2928 | status_idx, IGU_INT_ENABLE, 1); |
2929 | } | ||
2478 | } | 2930 | } |
2479 | 2931 | ||
2480 | static int cnic_service_bnx2x(void *data, void *status_blk) | 2932 | static int cnic_service_bnx2x(void *data, void *status_blk) |
@@ -2883,7 +3335,7 @@ static void cnic_cm_cleanup(struct cnic_sock *csk) | |||
2883 | struct cnic_dev *dev = csk->dev; | 3335 | struct cnic_dev *dev = csk->dev; |
2884 | struct cnic_local *cp = dev->cnic_priv; | 3336 | struct cnic_local *cp = dev->cnic_priv; |
2885 | 3337 | ||
2886 | cnic_free_id(&cp->csk_port_tbl, csk->src_port); | 3338 | cnic_free_id(&cp->csk_port_tbl, be16_to_cpu(csk->src_port)); |
2887 | csk->src_port = 0; | 3339 | csk->src_port = 0; |
2888 | } | 3340 | } |
2889 | } | 3341 | } |
@@ -3014,7 +3466,8 @@ static int cnic_get_route(struct cnic_sock *csk, struct cnic_sockaddr *saddr) | |||
3014 | int is_v6, rc = 0; | 3466 | int is_v6, rc = 0; |
3015 | struct dst_entry *dst = NULL; | 3467 | struct dst_entry *dst = NULL; |
3016 | struct net_device *realdev; | 3468 | struct net_device *realdev; |
3017 | u32 local_port; | 3469 | __be16 local_port; |
3470 | u32 port_id; | ||
3018 | 3471 | ||
3019 | if (saddr->local.v6.sin6_family == AF_INET6 && | 3472 | if (saddr->local.v6.sin6_family == AF_INET6 && |
3020 | saddr->remote.v6.sin6_family == AF_INET6) | 3473 | saddr->remote.v6.sin6_family == AF_INET6) |
@@ -3054,19 +3507,21 @@ static int cnic_get_route(struct cnic_sock *csk, struct cnic_sockaddr *saddr) | |||
3054 | } | 3507 | } |
3055 | } | 3508 | } |
3056 | 3509 | ||
3057 | if (local_port >= CNIC_LOCAL_PORT_MIN && | 3510 | port_id = be16_to_cpu(local_port); |
3058 | local_port < CNIC_LOCAL_PORT_MAX) { | 3511 | if (port_id >= CNIC_LOCAL_PORT_MIN && |
3059 | if (cnic_alloc_id(&cp->csk_port_tbl, local_port)) | 3512 | port_id < CNIC_LOCAL_PORT_MAX) { |
3060 | local_port = 0; | 3513 | if (cnic_alloc_id(&cp->csk_port_tbl, port_id)) |
3514 | port_id = 0; | ||
3061 | } else | 3515 | } else |
3062 | local_port = 0; | 3516 | port_id = 0; |
3063 | 3517 | ||
3064 | if (!local_port) { | 3518 | if (!port_id) { |
3065 | local_port = cnic_alloc_new_id(&cp->csk_port_tbl); | 3519 | port_id = cnic_alloc_new_id(&cp->csk_port_tbl); |
3066 | if (local_port == -1) { | 3520 | if (port_id == -1) { |
3067 | rc = -ENOMEM; | 3521 | rc = -ENOMEM; |
3068 | goto err_out; | 3522 | goto err_out; |
3069 | } | 3523 | } |
3524 | local_port = cpu_to_be16(port_id); | ||
3070 | } | 3525 | } |
3071 | csk->src_port = local_port; | 3526 | csk->src_port = local_port; |
3072 | 3527 | ||
@@ -3208,6 +3663,18 @@ done: | |||
3208 | csk_put(csk); | 3663 | csk_put(csk); |
3209 | } | 3664 | } |
3210 | 3665 | ||
3666 | static void cnic_process_fcoe_term_conn(struct cnic_dev *dev, struct kcqe *kcqe) | ||
3667 | { | ||
3668 | struct cnic_local *cp = dev->cnic_priv; | ||
3669 | struct fcoe_kcqe *fc_kcqe = (struct fcoe_kcqe *) kcqe; | ||
3670 | u32 l5_cid = fc_kcqe->fcoe_conn_id + BNX2X_FCOE_L5_CID_BASE; | ||
3671 | struct cnic_context *ctx = &cp->ctx_tbl[l5_cid]; | ||
3672 | |||
3673 | ctx->timestamp = jiffies; | ||
3674 | ctx->wait_cond = 1; | ||
3675 | wake_up(&ctx->waitq); | ||
3676 | } | ||
3677 | |||
3211 | static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe) | 3678 | static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe) |
3212 | { | 3679 | { |
3213 | struct cnic_local *cp = dev->cnic_priv; | 3680 | struct cnic_local *cp = dev->cnic_priv; |
@@ -3216,6 +3683,10 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe) | |||
3216 | u32 l5_cid; | 3683 | u32 l5_cid; |
3217 | struct cnic_sock *csk; | 3684 | struct cnic_sock *csk; |
3218 | 3685 | ||
3686 | if (opcode == FCOE_RAMROD_CMD_ID_TERMINATE_CONN) { | ||
3687 | cnic_process_fcoe_term_conn(dev, kcqe); | ||
3688 | return; | ||
3689 | } | ||
3219 | if (opcode == L4_KCQE_OPCODE_VALUE_OFFLOAD_PG || | 3690 | if (opcode == L4_KCQE_OPCODE_VALUE_OFFLOAD_PG || |
3220 | opcode == L4_KCQE_OPCODE_VALUE_UPDATE_PG) { | 3691 | opcode == L4_KCQE_OPCODE_VALUE_UPDATE_PG) { |
3221 | cnic_cm_process_offld_pg(dev, l4kcqe); | 3692 | cnic_cm_process_offld_pg(dev, l4kcqe); |
@@ -3852,7 +4323,7 @@ static void cnic_shutdown_bnx2_rx_ring(struct cnic_dev *dev) | |||
3852 | 4323 | ||
3853 | memset(&l2kwqe, 0, sizeof(l2kwqe)); | 4324 | memset(&l2kwqe, 0, sizeof(l2kwqe)); |
3854 | wqes[0] = &l2kwqe; | 4325 | wqes[0] = &l2kwqe; |
3855 | l2kwqe.kwqe_op_flag = (L2_LAYER_CODE << KWQE_FLAGS_LAYER_SHIFT) | | 4326 | l2kwqe.kwqe_op_flag = (L2_LAYER_CODE << KWQE_LAYER_SHIFT) | |
3856 | (L2_KWQE_OPCODE_VALUE_FLUSH << | 4327 | (L2_KWQE_OPCODE_VALUE_FLUSH << |
3857 | KWQE_OPCODE_SHIFT) | 2; | 4328 | KWQE_OPCODE_SHIFT) | 2; |
3858 | dev->submit_kwqes(dev, wqes, 1); | 4329 | dev->submit_kwqes(dev, wqes, 1); |
@@ -4106,7 +4577,7 @@ static void cnic_init_bnx2x_tx_ring(struct cnic_dev *dev, | |||
4106 | struct host_sp_status_block *sb = cp->bnx2x_def_status_blk; | 4577 | struct host_sp_status_block *sb = cp->bnx2x_def_status_blk; |
4107 | int port = CNIC_PORT(cp); | 4578 | int port = CNIC_PORT(cp); |
4108 | int i; | 4579 | int i; |
4109 | int cli = BNX2X_ISCSI_CL_ID(CNIC_E1HVN(cp)); | 4580 | u32 cli = cp->ethdev->iscsi_l2_client_id; |
4110 | u32 val; | 4581 | u32 val; |
4111 | 4582 | ||
4112 | memset(txbd, 0, BCM_PAGE_SIZE); | 4583 | memset(txbd, 0, BCM_PAGE_SIZE); |
@@ -4167,7 +4638,7 @@ static void cnic_init_bnx2x_rx_ring(struct cnic_dev *dev, | |||
4167 | struct host_sp_status_block *sb = cp->bnx2x_def_status_blk; | 4638 | struct host_sp_status_block *sb = cp->bnx2x_def_status_blk; |
4168 | int i; | 4639 | int i; |
4169 | int port = CNIC_PORT(cp); | 4640 | int port = CNIC_PORT(cp); |
4170 | int cli = BNX2X_ISCSI_CL_ID(CNIC_E1HVN(cp)); | 4641 | u32 cli = cp->ethdev->iscsi_l2_client_id; |
4171 | int cl_qzone_id = BNX2X_CL_QZONE_ID(cp, cli); | 4642 | int cl_qzone_id = BNX2X_CL_QZONE_ID(cp, cli); |
4172 | u32 val; | 4643 | u32 val; |
4173 | dma_addr_t ring_map = udev->l2_ring_map; | 4644 | dma_addr_t ring_map = udev->l2_ring_map; |
@@ -4231,12 +4702,39 @@ static void cnic_init_bnx2x_rx_ring(struct cnic_dev *dev, | |||
4231 | 4702 | ||
4232 | cp->rx_cons_ptr = | 4703 | cp->rx_cons_ptr = |
4233 | &sb->sp_sb.index_values[HC_SP_INDEX_ETH_ISCSI_RX_CQ_CONS]; | 4704 | &sb->sp_sb.index_values[HC_SP_INDEX_ETH_ISCSI_RX_CQ_CONS]; |
4705 | cp->rx_cons = *cp->rx_cons_ptr; | ||
4706 | } | ||
4707 | |||
4708 | static int cnic_read_bnx2x_iscsi_mac(struct cnic_dev *dev, u32 upper_addr, | ||
4709 | u32 lower_addr) | ||
4710 | { | ||
4711 | u32 val; | ||
4712 | u8 mac[6]; | ||
4713 | |||
4714 | val = CNIC_RD(dev, upper_addr); | ||
4715 | |||
4716 | mac[0] = (u8) (val >> 8); | ||
4717 | mac[1] = (u8) val; | ||
4718 | |||
4719 | val = CNIC_RD(dev, lower_addr); | ||
4720 | |||
4721 | mac[2] = (u8) (val >> 24); | ||
4722 | mac[3] = (u8) (val >> 16); | ||
4723 | mac[4] = (u8) (val >> 8); | ||
4724 | mac[5] = (u8) val; | ||
4725 | |||
4726 | if (is_valid_ether_addr(mac)) { | ||
4727 | memcpy(dev->mac_addr, mac, 6); | ||
4728 | return 0; | ||
4729 | } else { | ||
4730 | return -EINVAL; | ||
4731 | } | ||
4234 | } | 4732 | } |
4235 | 4733 | ||
4236 | static void cnic_get_bnx2x_iscsi_info(struct cnic_dev *dev) | 4734 | static void cnic_get_bnx2x_iscsi_info(struct cnic_dev *dev) |
4237 | { | 4735 | { |
4238 | struct cnic_local *cp = dev->cnic_priv; | 4736 | struct cnic_local *cp = dev->cnic_priv; |
4239 | u32 base, base2, addr, val; | 4737 | u32 base, base2, addr, addr1, val; |
4240 | int port = CNIC_PORT(cp); | 4738 | int port = CNIC_PORT(cp); |
4241 | 4739 | ||
4242 | dev->max_iscsi_conn = 0; | 4740 | dev->max_iscsi_conn = 0; |
@@ -4249,20 +4747,10 @@ static void cnic_get_bnx2x_iscsi_info(struct cnic_dev *dev) | |||
4249 | addr = BNX2X_SHMEM_ADDR(base, | 4747 | addr = BNX2X_SHMEM_ADDR(base, |
4250 | dev_info.port_hw_config[port].iscsi_mac_upper); | 4748 | dev_info.port_hw_config[port].iscsi_mac_upper); |
4251 | 4749 | ||
4252 | val = CNIC_RD(dev, addr); | 4750 | addr1 = BNX2X_SHMEM_ADDR(base, |
4253 | |||
4254 | dev->mac_addr[0] = (u8) (val >> 8); | ||
4255 | dev->mac_addr[1] = (u8) val; | ||
4256 | |||
4257 | addr = BNX2X_SHMEM_ADDR(base, | ||
4258 | dev_info.port_hw_config[port].iscsi_mac_lower); | 4751 | dev_info.port_hw_config[port].iscsi_mac_lower); |
4259 | 4752 | ||
4260 | val = CNIC_RD(dev, addr); | 4753 | cnic_read_bnx2x_iscsi_mac(dev, addr, addr1); |
4261 | |||
4262 | dev->mac_addr[2] = (u8) (val >> 24); | ||
4263 | dev->mac_addr[3] = (u8) (val >> 16); | ||
4264 | dev->mac_addr[4] = (u8) (val >> 8); | ||
4265 | dev->mac_addr[5] = (u8) val; | ||
4266 | 4754 | ||
4267 | addr = BNX2X_SHMEM_ADDR(base, validity_map[port]); | 4755 | addr = BNX2X_SHMEM_ADDR(base, validity_map[port]); |
4268 | val = CNIC_RD(dev, addr); | 4756 | val = CNIC_RD(dev, addr); |
@@ -4278,6 +4766,10 @@ static void cnic_get_bnx2x_iscsi_info(struct cnic_dev *dev) | |||
4278 | val16 ^= 0x1e1e; | 4766 | val16 ^= 0x1e1e; |
4279 | dev->max_iscsi_conn = val16; | 4767 | dev->max_iscsi_conn = val16; |
4280 | } | 4768 | } |
4769 | |||
4770 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) | ||
4771 | dev->max_fcoe_conn = BNX2X_FCOE_NUM_CONNECTIONS; | ||
4772 | |||
4281 | if (BNX2X_CHIP_IS_E1H(cp->chip_id) || BNX2X_CHIP_IS_E2(cp->chip_id)) { | 4773 | if (BNX2X_CHIP_IS_E1H(cp->chip_id) || BNX2X_CHIP_IS_E2(cp->chip_id)) { |
4282 | int func = CNIC_FUNC(cp); | 4774 | int func = CNIC_FUNC(cp); |
4283 | u32 mf_cfg_addr; | 4775 | u32 mf_cfg_addr; |
@@ -4288,21 +4780,90 @@ static void cnic_get_bnx2x_iscsi_info(struct cnic_dev *dev) | |||
4288 | else | 4780 | else |
4289 | mf_cfg_addr = base + BNX2X_SHMEM_MF_BLK_OFFSET; | 4781 | mf_cfg_addr = base + BNX2X_SHMEM_MF_BLK_OFFSET; |
4290 | 4782 | ||
4291 | addr = mf_cfg_addr + | 4783 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { |
4292 | offsetof(struct mf_cfg, func_mf_config[func].e1hov_tag); | 4784 | /* Must determine if the MF is SD vs SI mode */ |
4785 | addr = BNX2X_SHMEM_ADDR(base, | ||
4786 | dev_info.shared_feature_config.config); | ||
4787 | val = CNIC_RD(dev, addr); | ||
4788 | if ((val & SHARED_FEAT_CFG_FORCE_SF_MODE_MASK) == | ||
4789 | SHARED_FEAT_CFG_FORCE_SF_MODE_SWITCH_INDEPT) { | ||
4790 | int rc; | ||
4791 | |||
4792 | /* MULTI_FUNCTION_SI mode */ | ||
4793 | addr = BNX2X_MF_CFG_ADDR(mf_cfg_addr, | ||
4794 | func_ext_config[func].func_cfg); | ||
4795 | val = CNIC_RD(dev, addr); | ||
4796 | if (!(val & MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD)) | ||
4797 | dev->max_iscsi_conn = 0; | ||
4798 | |||
4799 | if (!(val & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD)) | ||
4800 | dev->max_fcoe_conn = 0; | ||
4801 | |||
4802 | addr = BNX2X_MF_CFG_ADDR(mf_cfg_addr, | ||
4803 | func_ext_config[func]. | ||
4804 | iscsi_mac_addr_upper); | ||
4805 | addr1 = BNX2X_MF_CFG_ADDR(mf_cfg_addr, | ||
4806 | func_ext_config[func]. | ||
4807 | iscsi_mac_addr_lower); | ||
4808 | rc = cnic_read_bnx2x_iscsi_mac(dev, addr, | ||
4809 | addr1); | ||
4810 | if (rc && func > 1) | ||
4811 | dev->max_iscsi_conn = 0; | ||
4812 | |||
4813 | return; | ||
4814 | } | ||
4815 | } | ||
4816 | |||
4817 | addr = BNX2X_MF_CFG_ADDR(mf_cfg_addr, | ||
4818 | func_mf_config[func].e1hov_tag); | ||
4293 | 4819 | ||
4294 | val = CNIC_RD(dev, addr); | 4820 | val = CNIC_RD(dev, addr); |
4295 | val &= FUNC_MF_CFG_E1HOV_TAG_MASK; | 4821 | val &= FUNC_MF_CFG_E1HOV_TAG_MASK; |
4296 | if (val != FUNC_MF_CFG_E1HOV_TAG_DEFAULT) { | 4822 | if (val != FUNC_MF_CFG_E1HOV_TAG_DEFAULT) { |
4297 | addr = mf_cfg_addr + | 4823 | dev->max_fcoe_conn = 0; |
4298 | offsetof(struct mf_cfg, | 4824 | dev->max_iscsi_conn = 0; |
4299 | func_mf_config[func].config); | ||
4300 | val = CNIC_RD(dev, addr); | ||
4301 | val &= FUNC_MF_CFG_PROTOCOL_MASK; | ||
4302 | if (val != FUNC_MF_CFG_PROTOCOL_ISCSI) | ||
4303 | dev->max_iscsi_conn = 0; | ||
4304 | } | 4825 | } |
4305 | } | 4826 | } |
4827 | if (!is_valid_ether_addr(dev->mac_addr)) | ||
4828 | dev->max_iscsi_conn = 0; | ||
4829 | } | ||
4830 | |||
4831 | static void cnic_init_bnx2x_kcq(struct cnic_dev *dev) | ||
4832 | { | ||
4833 | struct cnic_local *cp = dev->cnic_priv; | ||
4834 | u32 pfid = cp->pfid; | ||
4835 | |||
4836 | cp->kcq1.io_addr = BAR_CSTRORM_INTMEM + | ||
4837 | CSTORM_ISCSI_EQ_PROD_OFFSET(pfid, 0); | ||
4838 | cp->kcq1.sw_prod_idx = 0; | ||
4839 | |||
4840 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { | ||
4841 | struct host_hc_status_block_e2 *sb = cp->status_blk.gen; | ||
4842 | |||
4843 | cp->kcq1.hw_prod_idx_ptr = | ||
4844 | &sb->sb.index_values[HC_INDEX_ISCSI_EQ_CONS]; | ||
4845 | cp->kcq1.status_idx_ptr = | ||
4846 | &sb->sb.running_index[SM_RX_ID]; | ||
4847 | } else { | ||
4848 | struct host_hc_status_block_e1x *sb = cp->status_blk.gen; | ||
4849 | |||
4850 | cp->kcq1.hw_prod_idx_ptr = | ||
4851 | &sb->sb.index_values[HC_INDEX_ISCSI_EQ_CONS]; | ||
4852 | cp->kcq1.status_idx_ptr = | ||
4853 | &sb->sb.running_index[SM_RX_ID]; | ||
4854 | } | ||
4855 | |||
4856 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { | ||
4857 | struct host_hc_status_block_e2 *sb = cp->status_blk.gen; | ||
4858 | |||
4859 | cp->kcq2.io_addr = BAR_USTRORM_INTMEM + | ||
4860 | USTORM_FCOE_EQ_PROD_OFFSET(pfid); | ||
4861 | cp->kcq2.sw_prod_idx = 0; | ||
4862 | cp->kcq2.hw_prod_idx_ptr = | ||
4863 | &sb->sb.index_values[HC_INDEX_FCOE_EQ_CONS]; | ||
4864 | cp->kcq2.status_idx_ptr = | ||
4865 | &sb->sb.running_index[SM_RX_ID]; | ||
4866 | } | ||
4306 | } | 4867 | } |
4307 | 4868 | ||
4308 | static int cnic_start_bnx2x_hw(struct cnic_dev *dev) | 4869 | static int cnic_start_bnx2x_hw(struct cnic_dev *dev) |
@@ -4335,28 +4896,19 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev) | |||
4335 | if (ret) | 4896 | if (ret) |
4336 | return -ENOMEM; | 4897 | return -ENOMEM; |
4337 | 4898 | ||
4338 | cp->bnx2x_igu_sb_id = ethdev->irq_arr[0].status_blk_num2; | ||
4339 | |||
4340 | cp->kcq1.io_addr = BAR_CSTRORM_INTMEM + | ||
4341 | CSTORM_ISCSI_EQ_PROD_OFFSET(pfid, 0); | ||
4342 | cp->kcq1.sw_prod_idx = 0; | ||
4343 | |||
4344 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { | 4899 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { |
4345 | struct host_hc_status_block_e2 *sb = cp->status_blk.gen; | 4900 | ret = cnic_init_id_tbl(&cp->fcoe_cid_tbl, |
4346 | 4901 | BNX2X_FCOE_NUM_CONNECTIONS, | |
4347 | cp->kcq1.hw_prod_idx_ptr = | 4902 | cp->fcoe_start_cid); |
4348 | &sb->sb.index_values[HC_INDEX_ISCSI_EQ_CONS]; | ||
4349 | cp->kcq1.status_idx_ptr = | ||
4350 | &sb->sb.running_index[SM_RX_ID]; | ||
4351 | } else { | ||
4352 | struct host_hc_status_block_e1x *sb = cp->status_blk.gen; | ||
4353 | 4903 | ||
4354 | cp->kcq1.hw_prod_idx_ptr = | 4904 | if (ret) |
4355 | &sb->sb.index_values[HC_INDEX_ISCSI_EQ_CONS]; | 4905 | return -ENOMEM; |
4356 | cp->kcq1.status_idx_ptr = | ||
4357 | &sb->sb.running_index[SM_RX_ID]; | ||
4358 | } | 4906 | } |
4359 | 4907 | ||
4908 | cp->bnx2x_igu_sb_id = ethdev->irq_arr[0].status_blk_num2; | ||
4909 | |||
4910 | cnic_init_bnx2x_kcq(dev); | ||
4911 | |||
4360 | cnic_get_bnx2x_iscsi_info(dev); | 4912 | cnic_get_bnx2x_iscsi_info(dev); |
4361 | 4913 | ||
4362 | /* Only 1 EQ */ | 4914 | /* Only 1 EQ */ |
@@ -4424,8 +4976,9 @@ static void cnic_init_rings(struct cnic_dev *dev) | |||
4424 | cnic_init_bnx2_rx_ring(dev); | 4976 | cnic_init_bnx2_rx_ring(dev); |
4425 | set_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags); | 4977 | set_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags); |
4426 | } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { | 4978 | } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { |
4427 | u32 cli = BNX2X_ISCSI_CL_ID(CNIC_E1HVN(cp)); | 4979 | u32 cli = cp->ethdev->iscsi_l2_client_id; |
4428 | u32 cl_qzone_id, type; | 4980 | u32 cid = cp->ethdev->iscsi_l2_cid; |
4981 | u32 cl_qzone_id; | ||
4429 | struct client_init_ramrod_data *data; | 4982 | struct client_init_ramrod_data *data; |
4430 | union l5cm_specific_data l5_data; | 4983 | union l5cm_specific_data l5_data; |
4431 | struct ustorm_eth_rx_producers rx_prods = {0}; | 4984 | struct ustorm_eth_rx_producers rx_prods = {0}; |
@@ -4457,15 +5010,10 @@ static void cnic_init_rings(struct cnic_dev *dev) | |||
4457 | l5_data.phy_address.lo = udev->l2_buf_map & 0xffffffff; | 5010 | l5_data.phy_address.lo = udev->l2_buf_map & 0xffffffff; |
4458 | l5_data.phy_address.hi = (u64) udev->l2_buf_map >> 32; | 5011 | l5_data.phy_address.hi = (u64) udev->l2_buf_map >> 32; |
4459 | 5012 | ||
4460 | type = (ETH_CONNECTION_TYPE << SPE_HDR_CONN_TYPE_SHIFT) | ||
4461 | & SPE_HDR_CONN_TYPE; | ||
4462 | type |= ((cp->pfid << SPE_HDR_FUNCTION_ID_SHIFT) & | ||
4463 | SPE_HDR_FUNCTION_ID); | ||
4464 | |||
4465 | set_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags); | 5013 | set_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags); |
4466 | 5014 | ||
4467 | cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_CLIENT_SETUP, | 5015 | cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_CLIENT_SETUP, |
4468 | BNX2X_ISCSI_L2_CID, type, &l5_data); | 5016 | cid, ETH_CONNECTION_TYPE, &l5_data); |
4469 | 5017 | ||
4470 | i = 0; | 5018 | i = 0; |
4471 | while (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags) && | 5019 | while (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags) && |
@@ -4476,7 +5024,7 @@ static void cnic_init_rings(struct cnic_dev *dev) | |||
4476 | netdev_err(dev->netdev, | 5024 | netdev_err(dev->netdev, |
4477 | "iSCSI CLIENT_SETUP did not complete\n"); | 5025 | "iSCSI CLIENT_SETUP did not complete\n"); |
4478 | cnic_spq_completion(dev, DRV_CTL_RET_L2_SPQ_CREDIT_CMD, 1); | 5026 | cnic_spq_completion(dev, DRV_CTL_RET_L2_SPQ_CREDIT_CMD, 1); |
4479 | cnic_ring_ctl(dev, BNX2X_ISCSI_L2_CID, cli, 1); | 5027 | cnic_ring_ctl(dev, cid, cli, 1); |
4480 | } | 5028 | } |
4481 | } | 5029 | } |
4482 | 5030 | ||
@@ -4491,19 +5039,19 @@ static void cnic_shutdown_rings(struct cnic_dev *dev) | |||
4491 | cnic_shutdown_bnx2_rx_ring(dev); | 5039 | cnic_shutdown_bnx2_rx_ring(dev); |
4492 | } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { | 5040 | } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { |
4493 | struct cnic_local *cp = dev->cnic_priv; | 5041 | struct cnic_local *cp = dev->cnic_priv; |
4494 | u32 cli = BNX2X_ISCSI_CL_ID(CNIC_E1HVN(cp)); | 5042 | u32 cli = cp->ethdev->iscsi_l2_client_id; |
5043 | u32 cid = cp->ethdev->iscsi_l2_cid; | ||
4495 | union l5cm_specific_data l5_data; | 5044 | union l5cm_specific_data l5_data; |
4496 | int i; | 5045 | int i; |
4497 | u32 type; | ||
4498 | 5046 | ||
4499 | cnic_ring_ctl(dev, BNX2X_ISCSI_L2_CID, cli, 0); | 5047 | cnic_ring_ctl(dev, cid, cli, 0); |
4500 | 5048 | ||
4501 | set_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); | 5049 | set_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); |
4502 | 5050 | ||
4503 | l5_data.phy_address.lo = cli; | 5051 | l5_data.phy_address.lo = cli; |
4504 | l5_data.phy_address.hi = 0; | 5052 | l5_data.phy_address.hi = 0; |
4505 | cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_HALT, | 5053 | cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_HALT, |
4506 | BNX2X_ISCSI_L2_CID, ETH_CONNECTION_TYPE, &l5_data); | 5054 | cid, ETH_CONNECTION_TYPE, &l5_data); |
4507 | i = 0; | 5055 | i = 0; |
4508 | while (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags) && | 5056 | while (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags) && |
4509 | ++i < 10) | 5057 | ++i < 10) |
@@ -4515,12 +5063,8 @@ static void cnic_shutdown_rings(struct cnic_dev *dev) | |||
4515 | cnic_spq_completion(dev, DRV_CTL_RET_L2_SPQ_CREDIT_CMD, 1); | 5063 | cnic_spq_completion(dev, DRV_CTL_RET_L2_SPQ_CREDIT_CMD, 1); |
4516 | 5064 | ||
4517 | memset(&l5_data, 0, sizeof(l5_data)); | 5065 | memset(&l5_data, 0, sizeof(l5_data)); |
4518 | type = (NONE_CONNECTION_TYPE << SPE_HDR_CONN_TYPE_SHIFT) | ||
4519 | & SPE_HDR_CONN_TYPE; | ||
4520 | type |= ((cp->pfid << SPE_HDR_FUNCTION_ID_SHIFT) & | ||
4521 | SPE_HDR_FUNCTION_ID); | ||
4522 | cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_COMMON_CFC_DEL, | 5066 | cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_COMMON_CFC_DEL, |
4523 | BNX2X_ISCSI_L2_CID, type, &l5_data); | 5067 | cid, NONE_CONNECTION_TYPE, &l5_data); |
4524 | msleep(10); | 5068 | msleep(10); |
4525 | } | 5069 | } |
4526 | clear_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags); | 5070 | clear_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags); |