diff options
Diffstat (limited to 'drivers/net/cnic.c')
| -rw-r--r-- | drivers/net/cnic.c | 1752 |
1 files changed, 1242 insertions, 510 deletions
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c index 09610323a948..11a92afdf982 100644 --- a/drivers/net/cnic.c +++ b/drivers/net/cnic.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
| 28 | #include <linux/ethtool.h> | 28 | #include <linux/ethtool.h> |
| 29 | #include <linux/if_vlan.h> | 29 | #include <linux/if_vlan.h> |
| 30 | #include <linux/prefetch.h> | ||
| 30 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) | 31 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) |
| 31 | #define BCM_VLAN 1 | 32 | #define BCM_VLAN 1 |
| 32 | #endif | 33 | #endif |
| @@ -59,11 +60,20 @@ MODULE_DESCRIPTION("Broadcom NetXtreme II CNIC Driver"); | |||
| 59 | MODULE_LICENSE("GPL"); | 60 | MODULE_LICENSE("GPL"); |
| 60 | MODULE_VERSION(CNIC_MODULE_VERSION); | 61 | MODULE_VERSION(CNIC_MODULE_VERSION); |
| 61 | 62 | ||
| 63 | /* cnic_dev_list modifications are protected by both rtnl and cnic_dev_lock */ | ||
| 62 | static LIST_HEAD(cnic_dev_list); | 64 | static LIST_HEAD(cnic_dev_list); |
| 65 | static LIST_HEAD(cnic_udev_list); | ||
| 63 | static DEFINE_RWLOCK(cnic_dev_lock); | 66 | static DEFINE_RWLOCK(cnic_dev_lock); |
| 64 | static DEFINE_MUTEX(cnic_lock); | 67 | static DEFINE_MUTEX(cnic_lock); |
| 65 | 68 | ||
| 66 | static struct cnic_ulp_ops *cnic_ulp_tbl[MAX_CNIC_ULP_TYPE]; | 69 | static struct cnic_ulp_ops __rcu *cnic_ulp_tbl[MAX_CNIC_ULP_TYPE]; |
| 70 | |||
| 71 | /* helper function, assuming cnic_lock is held */ | ||
| 72 | static inline struct cnic_ulp_ops *cnic_ulp_tbl_prot(int type) | ||
| 73 | { | ||
| 74 | return rcu_dereference_protected(cnic_ulp_tbl[type], | ||
| 75 | lockdep_is_held(&cnic_lock)); | ||
| 76 | } | ||
| 67 | 77 | ||
| 68 | static int cnic_service_bnx2(void *, void *); | 78 | static int cnic_service_bnx2(void *, void *); |
| 69 | static int cnic_service_bnx2x(void *, void *); | 79 | static int cnic_service_bnx2x(void *, void *); |
| @@ -81,29 +91,34 @@ static struct cnic_ops cnic_bnx2x_ops = { | |||
| 81 | .cnic_ctl = cnic_ctl, | 91 | .cnic_ctl = cnic_ctl, |
| 82 | }; | 92 | }; |
| 83 | 93 | ||
| 94 | static struct workqueue_struct *cnic_wq; | ||
| 95 | |||
| 84 | static void cnic_shutdown_rings(struct cnic_dev *); | 96 | static void cnic_shutdown_rings(struct cnic_dev *); |
| 85 | static void cnic_init_rings(struct cnic_dev *); | 97 | static void cnic_init_rings(struct cnic_dev *); |
| 86 | static int cnic_cm_set_pg(struct cnic_sock *); | 98 | static int cnic_cm_set_pg(struct cnic_sock *); |
| 87 | 99 | ||
| 88 | static int cnic_uio_open(struct uio_info *uinfo, struct inode *inode) | 100 | static int cnic_uio_open(struct uio_info *uinfo, struct inode *inode) |
| 89 | { | 101 | { |
| 90 | struct cnic_dev *dev = uinfo->priv; | 102 | struct cnic_uio_dev *udev = uinfo->priv; |
| 91 | struct cnic_local *cp = dev->cnic_priv; | 103 | struct cnic_dev *dev; |
| 92 | 104 | ||
| 93 | if (!capable(CAP_NET_ADMIN)) | 105 | if (!capable(CAP_NET_ADMIN)) |
| 94 | return -EPERM; | 106 | return -EPERM; |
| 95 | 107 | ||
| 96 | if (cp->uio_dev != -1) | 108 | if (udev->uio_dev != -1) |
| 97 | return -EBUSY; | 109 | return -EBUSY; |
| 98 | 110 | ||
| 99 | rtnl_lock(); | 111 | rtnl_lock(); |
| 100 | if (!test_bit(CNIC_F_CNIC_UP, &dev->flags)) { | 112 | dev = udev->dev; |
| 113 | |||
| 114 | if (!dev || !test_bit(CNIC_F_CNIC_UP, &dev->flags)) { | ||
| 101 | rtnl_unlock(); | 115 | rtnl_unlock(); |
| 102 | return -ENODEV; | 116 | return -ENODEV; |
| 103 | } | 117 | } |
| 104 | 118 | ||
| 105 | cp->uio_dev = iminor(inode); | 119 | udev->uio_dev = iminor(inode); |
| 106 | 120 | ||
| 121 | cnic_shutdown_rings(dev); | ||
| 107 | cnic_init_rings(dev); | 122 | cnic_init_rings(dev); |
| 108 | rtnl_unlock(); | 123 | rtnl_unlock(); |
| 109 | 124 | ||
| @@ -112,12 +127,9 @@ static int cnic_uio_open(struct uio_info *uinfo, struct inode *inode) | |||
| 112 | 127 | ||
| 113 | static int cnic_uio_close(struct uio_info *uinfo, struct inode *inode) | 128 | static int cnic_uio_close(struct uio_info *uinfo, struct inode *inode) |
| 114 | { | 129 | { |
| 115 | struct cnic_dev *dev = uinfo->priv; | 130 | struct cnic_uio_dev *udev = uinfo->priv; |
| 116 | struct cnic_local *cp = dev->cnic_priv; | ||
| 117 | 131 | ||
| 118 | cnic_shutdown_rings(dev); | 132 | udev->uio_dev = -1; |
| 119 | |||
| 120 | cp->uio_dev = -1; | ||
| 121 | return 0; | 133 | return 0; |
| 122 | } | 134 | } |
| 123 | 135 | ||
| @@ -242,14 +254,14 @@ static int cnic_in_use(struct cnic_sock *csk) | |||
| 242 | return test_bit(SK_F_INUSE, &csk->flags); | 254 | return test_bit(SK_F_INUSE, &csk->flags); |
| 243 | } | 255 | } |
| 244 | 256 | ||
| 245 | static void cnic_kwq_completion(struct cnic_dev *dev, u32 count) | 257 | static void cnic_spq_completion(struct cnic_dev *dev, int cmd, u32 count) |
| 246 | { | 258 | { |
| 247 | struct cnic_local *cp = dev->cnic_priv; | 259 | struct cnic_local *cp = dev->cnic_priv; |
| 248 | struct cnic_eth_dev *ethdev = cp->ethdev; | 260 | struct cnic_eth_dev *ethdev = cp->ethdev; |
| 249 | struct drv_ctl_info info; | 261 | struct drv_ctl_info info; |
| 250 | 262 | ||
| 251 | info.cmd = DRV_CTL_COMPLETION_CMD; | 263 | info.cmd = cmd; |
| 252 | info.data.comp.comp_count = count; | 264 | info.data.credit.credit_count = count; |
| 253 | ethdev->drv_ctl(dev->netdev, &info); | 265 | ethdev->drv_ctl(dev->netdev, &info); |
| 254 | } | 266 | } |
| 255 | 267 | ||
| @@ -274,8 +286,10 @@ static int cnic_send_nlmsg(struct cnic_local *cp, u32 type, | |||
| 274 | u16 len = 0; | 286 | u16 len = 0; |
| 275 | u32 msg_type = ISCSI_KEVENT_IF_DOWN; | 287 | u32 msg_type = ISCSI_KEVENT_IF_DOWN; |
| 276 | struct cnic_ulp_ops *ulp_ops; | 288 | struct cnic_ulp_ops *ulp_ops; |
| 289 | struct cnic_uio_dev *udev = cp->udev; | ||
| 290 | int rc = 0, retry = 0; | ||
| 277 | 291 | ||
| 278 | if (cp->uio_dev == -1) | 292 | if (!udev || udev->uio_dev == -1) |
| 279 | return -ENODEV; | 293 | return -ENODEV; |
| 280 | 294 | ||
| 281 | if (csk) { | 295 | if (csk) { |
| @@ -298,14 +312,26 @@ static int cnic_send_nlmsg(struct cnic_local *cp, u32 type, | |||
| 298 | path_req.pmtu = csk->mtu; | 312 | path_req.pmtu = csk->mtu; |
| 299 | } | 313 | } |
| 300 | 314 | ||
| 301 | rcu_read_lock(); | 315 | while (retry < 3) { |
| 302 | ulp_ops = rcu_dereference(cnic_ulp_tbl[CNIC_ULP_ISCSI]); | 316 | rc = 0; |
| 303 | if (ulp_ops) | 317 | rcu_read_lock(); |
| 304 | ulp_ops->iscsi_nl_send_msg(cp->dev, msg_type, buf, len); | 318 | ulp_ops = rcu_dereference(cnic_ulp_tbl[CNIC_ULP_ISCSI]); |
| 305 | rcu_read_unlock(); | 319 | if (ulp_ops) |
| 320 | rc = ulp_ops->iscsi_nl_send_msg( | ||
| 321 | cp->ulp_handle[CNIC_ULP_ISCSI], | ||
| 322 | msg_type, buf, len); | ||
| 323 | rcu_read_unlock(); | ||
| 324 | if (rc == 0 || msg_type != ISCSI_KEVENT_PATH_REQ) | ||
| 325 | break; | ||
| 326 | |||
| 327 | msleep(100); | ||
| 328 | retry++; | ||
| 329 | } | ||
| 306 | return 0; | 330 | return 0; |
| 307 | } | 331 | } |
| 308 | 332 | ||
| 333 | static void cnic_cm_upcall(struct cnic_local *, struct cnic_sock *, u8); | ||
| 334 | |||
| 309 | static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type, | 335 | static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type, |
| 310 | char *buf, u16 len) | 336 | char *buf, u16 len) |
| 311 | { | 337 | { |
| @@ -335,7 +361,9 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type, | |||
| 335 | } | 361 | } |
| 336 | csk = &cp->csk_tbl[l5_cid]; | 362 | csk = &cp->csk_tbl[l5_cid]; |
| 337 | csk_hold(csk); | 363 | csk_hold(csk); |
| 338 | if (cnic_in_use(csk)) { | 364 | if (cnic_in_use(csk) && |
| 365 | test_bit(SK_F_CONNECT_START, &csk->flags)) { | ||
| 366 | |||
| 339 | memcpy(csk->ha, path_resp->mac_addr, 6); | 367 | memcpy(csk->ha, path_resp->mac_addr, 6); |
| 340 | if (test_bit(SK_F_IPV6, &csk->flags)) | 368 | if (test_bit(SK_F_IPV6, &csk->flags)) |
| 341 | memcpy(&csk->src_ip[0], &path_resp->src.v6_addr, | 369 | memcpy(&csk->src_ip[0], &path_resp->src.v6_addr, |
| @@ -343,8 +371,16 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type, | |||
| 343 | else | 371 | else |
| 344 | memcpy(&csk->src_ip[0], &path_resp->src.v4_addr, | 372 | memcpy(&csk->src_ip[0], &path_resp->src.v4_addr, |
| 345 | sizeof(struct in_addr)); | 373 | sizeof(struct in_addr)); |
| 346 | if (is_valid_ether_addr(csk->ha)) | 374 | |
| 375 | if (is_valid_ether_addr(csk->ha)) { | ||
| 347 | cnic_cm_set_pg(csk); | 376 | cnic_cm_set_pg(csk); |
| 377 | } else if (!test_bit(SK_F_OFFLD_SCHED, &csk->flags) && | ||
| 378 | !test_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) { | ||
| 379 | |||
| 380 | cnic_cm_upcall(cp, csk, | ||
| 381 | L4_KCQE_OPCODE_VALUE_CONNECT_COMPLETE); | ||
| 382 | clear_bit(SK_F_CONNECT_START, &csk->flags); | ||
| 383 | } | ||
| 348 | } | 384 | } |
| 349 | csk_put(csk); | 385 | csk_put(csk); |
| 350 | rcu_read_unlock(); | 386 | rcu_read_unlock(); |
| @@ -398,20 +434,6 @@ static int cnic_abort_prep(struct cnic_sock *csk) | |||
| 398 | return 0; | 434 | return 0; |
| 399 | } | 435 | } |
| 400 | 436 | ||
| 401 | static void cnic_uio_stop(void) | ||
| 402 | { | ||
| 403 | struct cnic_dev *dev; | ||
| 404 | |||
| 405 | read_lock(&cnic_dev_lock); | ||
| 406 | list_for_each_entry(dev, &cnic_dev_list, list) { | ||
| 407 | struct cnic_local *cp = dev->cnic_priv; | ||
| 408 | |||
| 409 | if (cp->cnic_uinfo) | ||
| 410 | cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); | ||
| 411 | } | ||
| 412 | read_unlock(&cnic_dev_lock); | ||
| 413 | } | ||
| 414 | |||
| 415 | int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops) | 437 | int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops) |
| 416 | { | 438 | { |
| 417 | struct cnic_dev *dev; | 439 | struct cnic_dev *dev; |
| @@ -421,7 +443,7 @@ int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops) | |||
| 421 | return -EINVAL; | 443 | return -EINVAL; |
| 422 | } | 444 | } |
| 423 | mutex_lock(&cnic_lock); | 445 | mutex_lock(&cnic_lock); |
| 424 | if (cnic_ulp_tbl[ulp_type]) { | 446 | if (cnic_ulp_tbl_prot(ulp_type)) { |
| 425 | pr_err("%s: Type %d has already been registered\n", | 447 | pr_err("%s: Type %d has already been registered\n", |
| 426 | __func__, ulp_type); | 448 | __func__, ulp_type); |
| 427 | mutex_unlock(&cnic_lock); | 449 | mutex_unlock(&cnic_lock); |
| @@ -442,14 +464,12 @@ int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops) | |||
| 442 | 464 | ||
| 443 | /* Prevent race conditions with netdev_event */ | 465 | /* Prevent race conditions with netdev_event */ |
| 444 | rtnl_lock(); | 466 | rtnl_lock(); |
| 445 | read_lock(&cnic_dev_lock); | ||
| 446 | list_for_each_entry(dev, &cnic_dev_list, list) { | 467 | list_for_each_entry(dev, &cnic_dev_list, list) { |
| 447 | struct cnic_local *cp = dev->cnic_priv; | 468 | struct cnic_local *cp = dev->cnic_priv; |
| 448 | 469 | ||
| 449 | if (!test_and_set_bit(ULP_F_INIT, &cp->ulp_flags[ulp_type])) | 470 | if (!test_and_set_bit(ULP_F_INIT, &cp->ulp_flags[ulp_type])) |
| 450 | ulp_ops->cnic_init(dev); | 471 | ulp_ops->cnic_init(dev); |
| 451 | } | 472 | } |
| 452 | read_unlock(&cnic_dev_lock); | ||
| 453 | rtnl_unlock(); | 473 | rtnl_unlock(); |
| 454 | 474 | ||
| 455 | return 0; | 475 | return 0; |
| @@ -466,7 +486,7 @@ int cnic_unregister_driver(int ulp_type) | |||
| 466 | return -EINVAL; | 486 | return -EINVAL; |
| 467 | } | 487 | } |
| 468 | mutex_lock(&cnic_lock); | 488 | mutex_lock(&cnic_lock); |
| 469 | ulp_ops = cnic_ulp_tbl[ulp_type]; | 489 | ulp_ops = cnic_ulp_tbl_prot(ulp_type); |
| 470 | if (!ulp_ops) { | 490 | if (!ulp_ops) { |
| 471 | pr_err("%s: Type %d has not been registered\n", | 491 | pr_err("%s: Type %d has not been registered\n", |
| 472 | __func__, ulp_type); | 492 | __func__, ulp_type); |
| @@ -485,9 +505,6 @@ int cnic_unregister_driver(int ulp_type) | |||
| 485 | } | 505 | } |
| 486 | read_unlock(&cnic_dev_lock); | 506 | read_unlock(&cnic_dev_lock); |
| 487 | 507 | ||
| 488 | if (ulp_type == CNIC_ULP_ISCSI) | ||
| 489 | cnic_uio_stop(); | ||
| 490 | |||
| 491 | rcu_assign_pointer(cnic_ulp_tbl[ulp_type], NULL); | 508 | rcu_assign_pointer(cnic_ulp_tbl[ulp_type], NULL); |
| 492 | 509 | ||
| 493 | mutex_unlock(&cnic_lock); | 510 | mutex_unlock(&cnic_lock); |
| @@ -520,7 +537,7 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type, | |||
| 520 | return -EINVAL; | 537 | return -EINVAL; |
| 521 | } | 538 | } |
| 522 | mutex_lock(&cnic_lock); | 539 | mutex_lock(&cnic_lock); |
| 523 | if (cnic_ulp_tbl[ulp_type] == NULL) { | 540 | if (cnic_ulp_tbl_prot(ulp_type) == NULL) { |
| 524 | pr_err("%s: Driver with type %d has not been registered\n", | 541 | pr_err("%s: Driver with type %d has not been registered\n", |
| 525 | __func__, ulp_type); | 542 | __func__, ulp_type); |
| 526 | mutex_unlock(&cnic_lock); | 543 | mutex_unlock(&cnic_lock); |
| @@ -535,7 +552,7 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type, | |||
| 535 | 552 | ||
| 536 | clear_bit(ULP_F_START, &cp->ulp_flags[ulp_type]); | 553 | clear_bit(ULP_F_START, &cp->ulp_flags[ulp_type]); |
| 537 | cp->ulp_handle[ulp_type] = ulp_ctx; | 554 | cp->ulp_handle[ulp_type] = ulp_ctx; |
| 538 | ulp_ops = cnic_ulp_tbl[ulp_type]; | 555 | ulp_ops = cnic_ulp_tbl_prot(ulp_type); |
| 539 | rcu_assign_pointer(cp->ulp_ops[ulp_type], ulp_ops); | 556 | rcu_assign_pointer(cp->ulp_ops[ulp_type], ulp_ops); |
| 540 | cnic_hold(dev); | 557 | cnic_hold(dev); |
| 541 | 558 | ||
| @@ -571,6 +588,9 @@ static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type) | |||
| 571 | } | 588 | } |
| 572 | mutex_unlock(&cnic_lock); | 589 | mutex_unlock(&cnic_lock); |
| 573 | 590 | ||
| 591 | if (ulp_type == CNIC_ULP_ISCSI) | ||
| 592 | cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); | ||
| 593 | |||
| 574 | synchronize_rcu(); | 594 | synchronize_rcu(); |
| 575 | 595 | ||
| 576 | while (test_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[ulp_type]) && | 596 | while (test_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[ulp_type]) && |
| @@ -687,13 +707,13 @@ static void cnic_free_dma(struct cnic_dev *dev, struct cnic_dma *dma) | |||
| 687 | static void cnic_setup_page_tbl(struct cnic_dev *dev, struct cnic_dma *dma) | 707 | static void cnic_setup_page_tbl(struct cnic_dev *dev, struct cnic_dma *dma) |
| 688 | { | 708 | { |
| 689 | int i; | 709 | int i; |
| 690 | u32 *page_table = dma->pgtbl; | 710 | __le32 *page_table = (__le32 *) dma->pgtbl; |
| 691 | 711 | ||
| 692 | for (i = 0; i < dma->num_pages; i++) { | 712 | for (i = 0; i < dma->num_pages; i++) { |
| 693 | /* Each entry needs to be in big endian format. */ | 713 | /* Each entry needs to be in big endian format. */ |
| 694 | *page_table = (u32) ((u64) dma->pg_map_arr[i] >> 32); | 714 | *page_table = cpu_to_le32((u64) dma->pg_map_arr[i] >> 32); |
| 695 | page_table++; | 715 | page_table++; |
| 696 | *page_table = (u32) dma->pg_map_arr[i]; | 716 | *page_table = cpu_to_le32(dma->pg_map_arr[i] & 0xffffffff); |
| 697 | page_table++; | 717 | page_table++; |
| 698 | } | 718 | } |
| 699 | } | 719 | } |
| @@ -701,13 +721,13 @@ static void cnic_setup_page_tbl(struct cnic_dev *dev, struct cnic_dma *dma) | |||
| 701 | static void cnic_setup_page_tbl_le(struct cnic_dev *dev, struct cnic_dma *dma) | 721 | static void cnic_setup_page_tbl_le(struct cnic_dev *dev, struct cnic_dma *dma) |
| 702 | { | 722 | { |
| 703 | int i; | 723 | int i; |
| 704 | u32 *page_table = dma->pgtbl; | 724 | __le32 *page_table = (__le32 *) dma->pgtbl; |
| 705 | 725 | ||
| 706 | for (i = 0; i < dma->num_pages; i++) { | 726 | for (i = 0; i < dma->num_pages; i++) { |
| 707 | /* Each entry needs to be in little endian format. */ | 727 | /* Each entry needs to be in little endian format. */ |
| 708 | *page_table = dma->pg_map_arr[i] & 0xffffffff; | 728 | *page_table = cpu_to_le32(dma->pg_map_arr[i] & 0xffffffff); |
| 709 | page_table++; | 729 | page_table++; |
| 710 | *page_table = (u32) ((u64) dma->pg_map_arr[i] >> 32); | 730 | *page_table = cpu_to_le32((u64) dma->pg_map_arr[i] >> 32); |
| 711 | page_table++; | 731 | page_table++; |
| 712 | } | 732 | } |
| 713 | } | 733 | } |
| @@ -768,31 +788,45 @@ static void cnic_free_context(struct cnic_dev *dev) | |||
| 768 | } | 788 | } |
| 769 | } | 789 | } |
| 770 | 790 | ||
| 771 | static void cnic_free_resc(struct cnic_dev *dev) | 791 | static void __cnic_free_uio(struct cnic_uio_dev *udev) |
| 772 | { | 792 | { |
| 773 | struct cnic_local *cp = dev->cnic_priv; | 793 | uio_unregister_device(&udev->cnic_uinfo); |
| 774 | int i = 0; | ||
| 775 | 794 | ||
| 776 | if (cp->cnic_uinfo) { | 795 | if (udev->l2_buf) { |
| 777 | while (cp->uio_dev != -1 && i < 15) { | 796 | dma_free_coherent(&udev->pdev->dev, udev->l2_buf_size, |
| 778 | msleep(100); | 797 | udev->l2_buf, udev->l2_buf_map); |
| 779 | i++; | 798 | udev->l2_buf = NULL; |
| 780 | } | ||
| 781 | uio_unregister_device(cp->cnic_uinfo); | ||
| 782 | kfree(cp->cnic_uinfo); | ||
| 783 | cp->cnic_uinfo = NULL; | ||
| 784 | } | 799 | } |
| 785 | 800 | ||
| 786 | if (cp->l2_buf) { | 801 | if (udev->l2_ring) { |
| 787 | dma_free_coherent(&dev->pcidev->dev, cp->l2_buf_size, | 802 | dma_free_coherent(&udev->pdev->dev, udev->l2_ring_size, |
| 788 | cp->l2_buf, cp->l2_buf_map); | 803 | udev->l2_ring, udev->l2_ring_map); |
| 789 | cp->l2_buf = NULL; | 804 | udev->l2_ring = NULL; |
| 790 | } | 805 | } |
| 791 | 806 | ||
| 792 | if (cp->l2_ring) { | 807 | pci_dev_put(udev->pdev); |
| 793 | dma_free_coherent(&dev->pcidev->dev, cp->l2_ring_size, | 808 | kfree(udev); |
| 794 | cp->l2_ring, cp->l2_ring_map); | 809 | } |
| 795 | cp->l2_ring = NULL; | 810 | |
| 811 | static void cnic_free_uio(struct cnic_uio_dev *udev) | ||
| 812 | { | ||
| 813 | if (!udev) | ||
| 814 | return; | ||
| 815 | |||
| 816 | write_lock(&cnic_dev_lock); | ||
| 817 | list_del_init(&udev->list); | ||
| 818 | write_unlock(&cnic_dev_lock); | ||
| 819 | __cnic_free_uio(udev); | ||
| 820 | } | ||
| 821 | |||
| 822 | static void cnic_free_resc(struct cnic_dev *dev) | ||
| 823 | { | ||
| 824 | struct cnic_local *cp = dev->cnic_priv; | ||
| 825 | struct cnic_uio_dev *udev = cp->udev; | ||
| 826 | |||
| 827 | if (udev) { | ||
| 828 | udev->dev = NULL; | ||
| 829 | cp->udev = NULL; | ||
| 796 | } | 830 | } |
| 797 | 831 | ||
| 798 | cnic_free_context(dev); | 832 | cnic_free_context(dev); |
| @@ -804,12 +838,14 @@ static void cnic_free_resc(struct cnic_dev *dev) | |||
| 804 | cnic_free_dma(dev, &cp->conn_buf_info); | 838 | cnic_free_dma(dev, &cp->conn_buf_info); |
| 805 | cnic_free_dma(dev, &cp->kwq_info); | 839 | cnic_free_dma(dev, &cp->kwq_info); |
| 806 | cnic_free_dma(dev, &cp->kwq_16_data_info); | 840 | cnic_free_dma(dev, &cp->kwq_16_data_info); |
| 841 | cnic_free_dma(dev, &cp->kcq2.dma); | ||
| 807 | cnic_free_dma(dev, &cp->kcq1.dma); | 842 | cnic_free_dma(dev, &cp->kcq1.dma); |
| 808 | kfree(cp->iscsi_tbl); | 843 | kfree(cp->iscsi_tbl); |
| 809 | cp->iscsi_tbl = NULL; | 844 | cp->iscsi_tbl = NULL; |
| 810 | kfree(cp->ctx_tbl); | 845 | kfree(cp->ctx_tbl); |
| 811 | cp->ctx_tbl = NULL; | 846 | cp->ctx_tbl = NULL; |
| 812 | 847 | ||
| 848 | cnic_free_id_tbl(&cp->fcoe_cid_tbl); | ||
| 813 | cnic_free_id_tbl(&cp->cid_tbl); | 849 | cnic_free_id_tbl(&cp->cid_tbl); |
| 814 | } | 850 | } |
| 815 | 851 | ||
| @@ -894,37 +930,74 @@ static int cnic_alloc_kcq(struct cnic_dev *dev, struct kcq_info *info) | |||
| 894 | return 0; | 930 | return 0; |
| 895 | } | 931 | } |
| 896 | 932 | ||
| 897 | static int cnic_alloc_l2_rings(struct cnic_dev *dev, int pages) | 933 | static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages) |
| 898 | { | 934 | { |
| 899 | struct cnic_local *cp = dev->cnic_priv; | 935 | struct cnic_local *cp = dev->cnic_priv; |
| 936 | struct cnic_uio_dev *udev; | ||
| 900 | 937 | ||
| 901 | cp->l2_ring_size = pages * BCM_PAGE_SIZE; | 938 | read_lock(&cnic_dev_lock); |
| 902 | cp->l2_ring = dma_alloc_coherent(&dev->pcidev->dev, cp->l2_ring_size, | 939 | list_for_each_entry(udev, &cnic_udev_list, list) { |
| 903 | &cp->l2_ring_map, | 940 | if (udev->pdev == dev->pcidev) { |
| 904 | GFP_KERNEL | __GFP_COMP); | 941 | udev->dev = dev; |
| 905 | if (!cp->l2_ring) | 942 | cp->udev = udev; |
| 906 | return -ENOMEM; | 943 | read_unlock(&cnic_dev_lock); |
| 944 | return 0; | ||
| 945 | } | ||
| 946 | } | ||
| 947 | read_unlock(&cnic_dev_lock); | ||
| 907 | 948 | ||
| 908 | cp->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size; | 949 | udev = kzalloc(sizeof(struct cnic_uio_dev), GFP_ATOMIC); |
| 909 | cp->l2_buf_size = PAGE_ALIGN(cp->l2_buf_size); | 950 | if (!udev) |
| 910 | cp->l2_buf = dma_alloc_coherent(&dev->pcidev->dev, cp->l2_buf_size, | ||
| 911 | &cp->l2_buf_map, | ||
| 912 | GFP_KERNEL | __GFP_COMP); | ||
| 913 | if (!cp->l2_buf) | ||
| 914 | return -ENOMEM; | 951 | return -ENOMEM; |
| 915 | 952 | ||
| 953 | udev->uio_dev = -1; | ||
| 954 | |||
| 955 | udev->dev = dev; | ||
| 956 | udev->pdev = dev->pcidev; | ||
| 957 | udev->l2_ring_size = pages * BCM_PAGE_SIZE; | ||
| 958 | udev->l2_ring = dma_alloc_coherent(&udev->pdev->dev, udev->l2_ring_size, | ||
| 959 | &udev->l2_ring_map, | ||
| 960 | GFP_KERNEL | __GFP_COMP); | ||
| 961 | if (!udev->l2_ring) | ||
| 962 | goto err_udev; | ||
| 963 | |||
| 964 | udev->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size; | ||
| 965 | udev->l2_buf_size = PAGE_ALIGN(udev->l2_buf_size); | ||
| 966 | udev->l2_buf = dma_alloc_coherent(&udev->pdev->dev, udev->l2_buf_size, | ||
| 967 | &udev->l2_buf_map, | ||
| 968 | GFP_KERNEL | __GFP_COMP); | ||
| 969 | if (!udev->l2_buf) | ||
| 970 | goto err_dma; | ||
| 971 | |||
| 972 | write_lock(&cnic_dev_lock); | ||
| 973 | list_add(&udev->list, &cnic_udev_list); | ||
| 974 | write_unlock(&cnic_dev_lock); | ||
| 975 | |||
| 976 | pci_dev_get(udev->pdev); | ||
| 977 | |||
| 978 | cp->udev = udev; | ||
| 979 | |||
| 916 | return 0; | 980 | return 0; |
| 981 | err_dma: | ||
| 982 | dma_free_coherent(&udev->pdev->dev, udev->l2_ring_size, | ||
| 983 | udev->l2_ring, udev->l2_ring_map); | ||
| 984 | err_udev: | ||
| 985 | kfree(udev); | ||
| 986 | return -ENOMEM; | ||
| 917 | } | 987 | } |
| 918 | 988 | ||
| 919 | static int cnic_alloc_uio(struct cnic_dev *dev) { | 989 | static int cnic_init_uio(struct cnic_dev *dev) |
| 990 | { | ||
| 920 | struct cnic_local *cp = dev->cnic_priv; | 991 | struct cnic_local *cp = dev->cnic_priv; |
| 992 | struct cnic_uio_dev *udev = cp->udev; | ||
| 921 | struct uio_info *uinfo; | 993 | struct uio_info *uinfo; |
| 922 | int ret; | 994 | int ret = 0; |
| 923 | 995 | ||
| 924 | uinfo = kzalloc(sizeof(*uinfo), GFP_ATOMIC); | 996 | if (!udev) |
| 925 | if (!uinfo) | ||
| 926 | return -ENOMEM; | 997 | return -ENOMEM; |
| 927 | 998 | ||
| 999 | uinfo = &udev->cnic_uinfo; | ||
| 1000 | |||
| 928 | uinfo->mem[0].addr = dev->netdev->base_addr; | 1001 | uinfo->mem[0].addr = dev->netdev->base_addr; |
| 929 | uinfo->mem[0].internal_addr = dev->regview; | 1002 | uinfo->mem[0].internal_addr = dev->regview; |
| 930 | uinfo->mem[0].size = dev->netdev->mem_end - dev->netdev->mem_start; | 1003 | uinfo->mem[0].size = dev->netdev->mem_end - dev->netdev->mem_start; |
| @@ -932,7 +1005,7 @@ static int cnic_alloc_uio(struct cnic_dev *dev) { | |||
| 932 | 1005 | ||
| 933 | if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) { | 1006 | if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) { |
| 934 | uinfo->mem[1].addr = (unsigned long) cp->status_blk.gen & | 1007 | uinfo->mem[1].addr = (unsigned long) cp->status_blk.gen & |
| 935 | PAGE_MASK; | 1008 | PAGE_MASK; |
| 936 | if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) | 1009 | if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) |
| 937 | uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9; | 1010 | uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9; |
| 938 | else | 1011 | else |
| @@ -942,19 +1015,19 @@ static int cnic_alloc_uio(struct cnic_dev *dev) { | |||
| 942 | } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { | 1015 | } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { |
| 943 | uinfo->mem[1].addr = (unsigned long) cp->bnx2x_def_status_blk & | 1016 | uinfo->mem[1].addr = (unsigned long) cp->bnx2x_def_status_blk & |
| 944 | PAGE_MASK; | 1017 | PAGE_MASK; |
| 945 | uinfo->mem[1].size = sizeof(struct host_def_status_block); | 1018 | uinfo->mem[1].size = sizeof(*cp->bnx2x_def_status_blk); |
| 946 | 1019 | ||
| 947 | uinfo->name = "bnx2x_cnic"; | 1020 | uinfo->name = "bnx2x_cnic"; |
| 948 | } | 1021 | } |
| 949 | 1022 | ||
| 950 | uinfo->mem[1].memtype = UIO_MEM_LOGICAL; | 1023 | uinfo->mem[1].memtype = UIO_MEM_LOGICAL; |
| 951 | 1024 | ||
| 952 | uinfo->mem[2].addr = (unsigned long) cp->l2_ring; | 1025 | uinfo->mem[2].addr = (unsigned long) udev->l2_ring; |
| 953 | uinfo->mem[2].size = cp->l2_ring_size; | 1026 | uinfo->mem[2].size = udev->l2_ring_size; |
| 954 | uinfo->mem[2].memtype = UIO_MEM_LOGICAL; | 1027 | uinfo->mem[2].memtype = UIO_MEM_LOGICAL; |
| 955 | 1028 | ||
| 956 | uinfo->mem[3].addr = (unsigned long) cp->l2_buf; | 1029 | uinfo->mem[3].addr = (unsigned long) udev->l2_buf; |
| 957 | uinfo->mem[3].size = cp->l2_buf_size; | 1030 | uinfo->mem[3].size = udev->l2_buf_size; |
| 958 | uinfo->mem[3].memtype = UIO_MEM_LOGICAL; | 1031 | uinfo->mem[3].memtype = UIO_MEM_LOGICAL; |
| 959 | 1032 | ||
| 960 | uinfo->version = CNIC_MODULE_VERSION; | 1033 | uinfo->version = CNIC_MODULE_VERSION; |
| @@ -963,16 +1036,17 @@ static int cnic_alloc_uio(struct cnic_dev *dev) { | |||
| 963 | uinfo->open = cnic_uio_open; | 1036 | uinfo->open = cnic_uio_open; |
| 964 | uinfo->release = cnic_uio_close; | 1037 | uinfo->release = cnic_uio_close; |
| 965 | 1038 | ||
| 966 | uinfo->priv = dev; | 1039 | if (udev->uio_dev == -1) { |
| 1040 | if (!uinfo->priv) { | ||
| 1041 | uinfo->priv = udev; | ||
| 967 | 1042 | ||
| 968 | ret = uio_register_device(&dev->pcidev->dev, uinfo); | 1043 | ret = uio_register_device(&udev->pdev->dev, uinfo); |
| 969 | if (ret) { | 1044 | } |
| 970 | kfree(uinfo); | 1045 | } else { |
| 971 | return ret; | 1046 | cnic_init_rings(dev); |
| 972 | } | 1047 | } |
| 973 | 1048 | ||
| 974 | cp->cnic_uinfo = uinfo; | 1049 | return ret; |
| 975 | return 0; | ||
| 976 | } | 1050 | } |
| 977 | 1051 | ||
| 978 | static int cnic_alloc_bnx2_resc(struct cnic_dev *dev) | 1052 | static int cnic_alloc_bnx2_resc(struct cnic_dev *dev) |
| @@ -993,11 +1067,11 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev) | |||
| 993 | if (ret) | 1067 | if (ret) |
| 994 | goto error; | 1068 | goto error; |
| 995 | 1069 | ||
| 996 | ret = cnic_alloc_l2_rings(dev, 2); | 1070 | ret = cnic_alloc_uio_rings(dev, 2); |
| 997 | if (ret) | 1071 | if (ret) |
| 998 | goto error; | 1072 | goto error; |
| 999 | 1073 | ||
| 1000 | ret = cnic_alloc_uio(dev); | 1074 | ret = cnic_init_uio(dev); |
| 1001 | if (ret) | 1075 | if (ret) |
| 1002 | goto error; | 1076 | goto error; |
| 1003 | 1077 | ||
| @@ -1022,13 +1096,13 @@ static int cnic_alloc_bnx2x_context(struct cnic_dev *dev) | |||
| 1022 | if (blks > cp->ethdev->ctx_tbl_len) | 1096 | if (blks > cp->ethdev->ctx_tbl_len) |
| 1023 | return -ENOMEM; | 1097 | return -ENOMEM; |
| 1024 | 1098 | ||
| 1025 | cp->ctx_arr = kzalloc(blks * sizeof(struct cnic_ctx), GFP_KERNEL); | 1099 | cp->ctx_arr = kcalloc(blks, sizeof(struct cnic_ctx), GFP_KERNEL); |
| 1026 | if (cp->ctx_arr == NULL) | 1100 | if (cp->ctx_arr == NULL) |
| 1027 | return -ENOMEM; | 1101 | return -ENOMEM; |
| 1028 | 1102 | ||
| 1029 | cp->ctx_blks = blks; | 1103 | cp->ctx_blks = blks; |
| 1030 | cp->ctx_blk_size = ctx_blk_size; | 1104 | cp->ctx_blk_size = ctx_blk_size; |
| 1031 | if (BNX2X_CHIP_IS_E1H(cp->chip_id)) | 1105 | if (!BNX2X_CHIP_IS_57710(cp->chip_id)) |
| 1032 | cp->ctx_align = 0; | 1106 | cp->ctx_align = 0; |
| 1033 | else | 1107 | else |
| 1034 | cp->ctx_align = ctx_blk_size; | 1108 | cp->ctx_align = ctx_blk_size; |
| @@ -1063,12 +1137,24 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
| 1063 | int i, j, n, ret, pages; | 1137 | int i, j, n, ret, pages; |
| 1064 | struct cnic_dma *kwq_16_dma = &cp->kwq_16_data_info; | 1138 | struct cnic_dma *kwq_16_dma = &cp->kwq_16_data_info; |
| 1065 | 1139 | ||
| 1066 | cp->max_cid_space = MAX_ISCSI_TBL_SZ; | 1140 | cp->iro_arr = ethdev->iro_arr; |
| 1141 | |||
| 1142 | cp->max_cid_space = MAX_ISCSI_TBL_SZ + BNX2X_FCOE_NUM_CONNECTIONS; | ||
| 1067 | cp->iscsi_start_cid = start_cid; | 1143 | cp->iscsi_start_cid = start_cid; |
| 1144 | cp->fcoe_start_cid = start_cid + MAX_ISCSI_TBL_SZ; | ||
| 1145 | |||
| 1146 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { | ||
| 1147 | cp->max_cid_space += BNX2X_FCOE_NUM_CONNECTIONS; | ||
| 1148 | cp->fcoe_init_cid = ethdev->fcoe_init_cid; | ||
| 1149 | if (!cp->fcoe_init_cid) | ||
| 1150 | cp->fcoe_init_cid = 0x10; | ||
| 1151 | } | ||
| 1152 | |||
| 1068 | if (start_cid < BNX2X_ISCSI_START_CID) { | 1153 | if (start_cid < BNX2X_ISCSI_START_CID) { |
| 1069 | u32 delta = BNX2X_ISCSI_START_CID - start_cid; | 1154 | u32 delta = BNX2X_ISCSI_START_CID - start_cid; |
| 1070 | 1155 | ||
| 1071 | cp->iscsi_start_cid = BNX2X_ISCSI_START_CID; | 1156 | cp->iscsi_start_cid = BNX2X_ISCSI_START_CID; |
| 1157 | cp->fcoe_start_cid += delta; | ||
| 1072 | cp->max_cid_space += delta; | 1158 | cp->max_cid_space += delta; |
| 1073 | } | 1159 | } |
| 1074 | 1160 | ||
| @@ -1087,6 +1173,9 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
| 1087 | cp->ctx_tbl[i].ulp_proto_id = CNIC_ULP_ISCSI; | 1173 | cp->ctx_tbl[i].ulp_proto_id = CNIC_ULP_ISCSI; |
| 1088 | } | 1174 | } |
| 1089 | 1175 | ||
| 1176 | for (i = MAX_ISCSI_TBL_SZ; i < cp->max_cid_space; i++) | ||
| 1177 | cp->ctx_tbl[i].ulp_proto_id = CNIC_ULP_FCOE; | ||
| 1178 | |||
| 1090 | pages = PAGE_ALIGN(cp->max_cid_space * CNIC_KWQ16_DATA_SIZE) / | 1179 | pages = PAGE_ALIGN(cp->max_cid_space * CNIC_KWQ16_DATA_SIZE) / |
| 1091 | PAGE_SIZE; | 1180 | PAGE_SIZE; |
| 1092 | 1181 | ||
| @@ -1110,6 +1199,12 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
| 1110 | if (ret) | 1199 | if (ret) |
| 1111 | goto error; | 1200 | goto error; |
| 1112 | 1201 | ||
| 1202 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { | ||
| 1203 | ret = cnic_alloc_kcq(dev, &cp->kcq2); | ||
| 1204 | if (ret) | ||
| 1205 | goto error; | ||
| 1206 | } | ||
| 1207 | |||
| 1113 | pages = PAGE_ALIGN(BNX2X_ISCSI_NUM_CONNECTIONS * | 1208 | pages = PAGE_ALIGN(BNX2X_ISCSI_NUM_CONNECTIONS * |
| 1114 | BNX2X_ISCSI_CONN_BUF_SIZE) / PAGE_SIZE; | 1209 | BNX2X_ISCSI_CONN_BUF_SIZE) / PAGE_SIZE; |
| 1115 | ret = cnic_alloc_dma(dev, &cp->conn_buf_info, pages, 1); | 1210 | ret = cnic_alloc_dma(dev, &cp->conn_buf_info, pages, 1); |
| @@ -1127,15 +1222,13 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
| 1127 | 1222 | ||
| 1128 | cp->bnx2x_def_status_blk = cp->ethdev->irq_arr[1].status_blk; | 1223 | cp->bnx2x_def_status_blk = cp->ethdev->irq_arr[1].status_blk; |
| 1129 | 1224 | ||
| 1130 | memset(cp->status_blk.bnx2x, 0, sizeof(*cp->status_blk.bnx2x)); | ||
| 1131 | |||
| 1132 | cp->l2_rx_ring_size = 15; | 1225 | cp->l2_rx_ring_size = 15; |
| 1133 | 1226 | ||
| 1134 | ret = cnic_alloc_l2_rings(dev, 4); | 1227 | ret = cnic_alloc_uio_rings(dev, 4); |
| 1135 | if (ret) | 1228 | if (ret) |
| 1136 | goto error; | 1229 | goto error; |
| 1137 | 1230 | ||
| 1138 | ret = cnic_alloc_uio(dev); | 1231 | ret = cnic_init_uio(dev); |
| 1139 | if (ret) | 1232 | if (ret) |
| 1140 | goto error; | 1233 | goto error; |
| 1141 | 1234 | ||
| @@ -1205,13 +1298,19 @@ static int cnic_submit_kwqe_16(struct cnic_dev *dev, u32 cmd, u32 cid, | |||
| 1205 | struct cnic_local *cp = dev->cnic_priv; | 1298 | struct cnic_local *cp = dev->cnic_priv; |
| 1206 | struct l5cm_spe kwqe; | 1299 | struct l5cm_spe kwqe; |
| 1207 | struct kwqe_16 *kwq[1]; | 1300 | struct kwqe_16 *kwq[1]; |
| 1301 | u16 type_16; | ||
| 1208 | int ret; | 1302 | int ret; |
| 1209 | 1303 | ||
| 1210 | kwqe.hdr.conn_and_cmd_data = | 1304 | kwqe.hdr.conn_and_cmd_data = |
| 1211 | cpu_to_le32(((cmd << SPE_HDR_CMD_ID_SHIFT) | | 1305 | cpu_to_le32(((cmd << SPE_HDR_CMD_ID_SHIFT) | |
| 1212 | BNX2X_HW_CID(cid, cp->func))); | 1306 | BNX2X_HW_CID(cp, cid))); |
| 1213 | kwqe.hdr.type = cpu_to_le16(type); | 1307 | |
| 1214 | kwqe.hdr.reserved = 0; | 1308 | type_16 = (type << SPE_HDR_CONN_TYPE_SHIFT) & SPE_HDR_CONN_TYPE; |
| 1309 | type_16 |= (cp->pfid << SPE_HDR_FUNCTION_ID_SHIFT) & | ||
| 1310 | SPE_HDR_FUNCTION_ID; | ||
| 1311 | |||
| 1312 | kwqe.hdr.type = cpu_to_le16(type_16); | ||
| 1313 | kwqe.hdr.reserved1 = 0; | ||
| 1215 | kwqe.data.phy_address.lo = cpu_to_le32(l5_data->phy_address.lo); | 1314 | kwqe.data.phy_address.lo = cpu_to_le32(l5_data->phy_address.lo); |
| 1216 | kwqe.data.phy_address.hi = cpu_to_le32(l5_data->phy_address.hi); | 1315 | kwqe.data.phy_address.hi = cpu_to_le32(l5_data->phy_address.hi); |
| 1217 | 1316 | ||
| @@ -1246,8 +1345,8 @@ static int cnic_bnx2x_iscsi_init1(struct cnic_dev *dev, struct kwqe *kwqe) | |||
| 1246 | { | 1345 | { |
| 1247 | struct cnic_local *cp = dev->cnic_priv; | 1346 | struct cnic_local *cp = dev->cnic_priv; |
| 1248 | struct iscsi_kwqe_init1 *req1 = (struct iscsi_kwqe_init1 *) kwqe; | 1347 | struct iscsi_kwqe_init1 *req1 = (struct iscsi_kwqe_init1 *) kwqe; |
| 1249 | int func = cp->func, pages; | 1348 | int hq_bds, pages; |
| 1250 | int hq_bds; | 1349 | u32 pfid = cp->pfid; |
| 1251 | 1350 | ||
| 1252 | cp->num_iscsi_tasks = req1->num_tasks_per_conn; | 1351 | cp->num_iscsi_tasks = req1->num_tasks_per_conn; |
| 1253 | cp->num_ccells = req1->num_ccells_per_conn; | 1352 | cp->num_ccells = req1->num_ccells_per_conn; |
| @@ -1264,60 +1363,60 @@ static int cnic_bnx2x_iscsi_init1(struct cnic_dev *dev, struct kwqe *kwqe) | |||
| 1264 | return 0; | 1363 | return 0; |
| 1265 | 1364 | ||
| 1266 | /* init Tstorm RAM */ | 1365 | /* init Tstorm RAM */ |
| 1267 | CNIC_WR16(dev, BAR_TSTRORM_INTMEM + TSTORM_ISCSI_RQ_SIZE_OFFSET(func), | 1366 | CNIC_WR16(dev, BAR_TSTRORM_INTMEM + TSTORM_ISCSI_RQ_SIZE_OFFSET(pfid), |
| 1268 | req1->rq_num_wqes); | 1367 | req1->rq_num_wqes); |
| 1269 | CNIC_WR16(dev, BAR_TSTRORM_INTMEM + TSTORM_ISCSI_PAGE_SIZE_OFFSET(func), | 1368 | CNIC_WR16(dev, BAR_TSTRORM_INTMEM + TSTORM_ISCSI_PAGE_SIZE_OFFSET(pfid), |
| 1270 | PAGE_SIZE); | 1369 | PAGE_SIZE); |
| 1271 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + | 1370 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + |
| 1272 | TSTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(func), PAGE_SHIFT); | 1371 | TSTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(pfid), PAGE_SHIFT); |
| 1273 | CNIC_WR16(dev, BAR_TSTRORM_INTMEM + | 1372 | CNIC_WR16(dev, BAR_TSTRORM_INTMEM + |
| 1274 | TSTORM_ISCSI_NUM_OF_TASKS_OFFSET(func), | 1373 | TSTORM_ISCSI_NUM_OF_TASKS_OFFSET(pfid), |
| 1275 | req1->num_tasks_per_conn); | 1374 | req1->num_tasks_per_conn); |
| 1276 | 1375 | ||
| 1277 | /* init Ustorm RAM */ | 1376 | /* init Ustorm RAM */ |
| 1278 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + | 1377 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + |
| 1279 | USTORM_ISCSI_RQ_BUFFER_SIZE_OFFSET(func), | 1378 | USTORM_ISCSI_RQ_BUFFER_SIZE_OFFSET(pfid), |
| 1280 | req1->rq_buffer_size); | 1379 | req1->rq_buffer_size); |
| 1281 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + USTORM_ISCSI_PAGE_SIZE_OFFSET(func), | 1380 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + USTORM_ISCSI_PAGE_SIZE_OFFSET(pfid), |
| 1282 | PAGE_SIZE); | 1381 | PAGE_SIZE); |
| 1283 | CNIC_WR8(dev, BAR_USTRORM_INTMEM + | 1382 | CNIC_WR8(dev, BAR_USTRORM_INTMEM + |
| 1284 | USTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(func), PAGE_SHIFT); | 1383 | USTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(pfid), PAGE_SHIFT); |
| 1285 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + | 1384 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + |
| 1286 | USTORM_ISCSI_NUM_OF_TASKS_OFFSET(func), | 1385 | USTORM_ISCSI_NUM_OF_TASKS_OFFSET(pfid), |
| 1287 | req1->num_tasks_per_conn); | 1386 | req1->num_tasks_per_conn); |
| 1288 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + USTORM_ISCSI_RQ_SIZE_OFFSET(func), | 1387 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + USTORM_ISCSI_RQ_SIZE_OFFSET(pfid), |
| 1289 | req1->rq_num_wqes); | 1388 | req1->rq_num_wqes); |
| 1290 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + USTORM_ISCSI_CQ_SIZE_OFFSET(func), | 1389 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + USTORM_ISCSI_CQ_SIZE_OFFSET(pfid), |
| 1291 | req1->cq_num_wqes); | 1390 | req1->cq_num_wqes); |
| 1292 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + USTORM_ISCSI_R2TQ_SIZE_OFFSET(func), | 1391 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + USTORM_ISCSI_R2TQ_SIZE_OFFSET(pfid), |
| 1293 | cp->num_iscsi_tasks * BNX2X_ISCSI_MAX_PENDING_R2TS); | 1392 | cp->num_iscsi_tasks * BNX2X_ISCSI_MAX_PENDING_R2TS); |
| 1294 | 1393 | ||
| 1295 | /* init Xstorm RAM */ | 1394 | /* init Xstorm RAM */ |
| 1296 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + XSTORM_ISCSI_PAGE_SIZE_OFFSET(func), | 1395 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + XSTORM_ISCSI_PAGE_SIZE_OFFSET(pfid), |
| 1297 | PAGE_SIZE); | 1396 | PAGE_SIZE); |
| 1298 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + | 1397 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + |
| 1299 | XSTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(func), PAGE_SHIFT); | 1398 | XSTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(pfid), PAGE_SHIFT); |
| 1300 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + | 1399 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + |
| 1301 | XSTORM_ISCSI_NUM_OF_TASKS_OFFSET(func), | 1400 | XSTORM_ISCSI_NUM_OF_TASKS_OFFSET(pfid), |
| 1302 | req1->num_tasks_per_conn); | 1401 | req1->num_tasks_per_conn); |
| 1303 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + XSTORM_ISCSI_HQ_SIZE_OFFSET(func), | 1402 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + XSTORM_ISCSI_HQ_SIZE_OFFSET(pfid), |
| 1304 | hq_bds); | 1403 | hq_bds); |
| 1305 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + XSTORM_ISCSI_SQ_SIZE_OFFSET(func), | 1404 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + XSTORM_ISCSI_SQ_SIZE_OFFSET(pfid), |
| 1306 | req1->num_tasks_per_conn); | 1405 | req1->num_tasks_per_conn); |
| 1307 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + XSTORM_ISCSI_R2TQ_SIZE_OFFSET(func), | 1406 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + XSTORM_ISCSI_R2TQ_SIZE_OFFSET(pfid), |
| 1308 | cp->num_iscsi_tasks * BNX2X_ISCSI_MAX_PENDING_R2TS); | 1407 | cp->num_iscsi_tasks * BNX2X_ISCSI_MAX_PENDING_R2TS); |
| 1309 | 1408 | ||
| 1310 | /* init Cstorm RAM */ | 1409 | /* init Cstorm RAM */ |
| 1311 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + CSTORM_ISCSI_PAGE_SIZE_OFFSET(func), | 1410 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + CSTORM_ISCSI_PAGE_SIZE_OFFSET(pfid), |
| 1312 | PAGE_SIZE); | 1411 | PAGE_SIZE); |
| 1313 | CNIC_WR8(dev, BAR_CSTRORM_INTMEM + | 1412 | CNIC_WR8(dev, BAR_CSTRORM_INTMEM + |
| 1314 | CSTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(func), PAGE_SHIFT); | 1413 | CSTORM_ISCSI_PAGE_SIZE_LOG_OFFSET(pfid), PAGE_SHIFT); |
| 1315 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + | 1414 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + |
| 1316 | CSTORM_ISCSI_NUM_OF_TASKS_OFFSET(func), | 1415 | CSTORM_ISCSI_NUM_OF_TASKS_OFFSET(pfid), |
| 1317 | req1->num_tasks_per_conn); | 1416 | req1->num_tasks_per_conn); |
| 1318 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + CSTORM_ISCSI_CQ_SIZE_OFFSET(func), | 1417 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + CSTORM_ISCSI_CQ_SIZE_OFFSET(pfid), |
| 1319 | req1->cq_num_wqes); | 1418 | req1->cq_num_wqes); |
| 1320 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + CSTORM_ISCSI_HQ_SIZE_OFFSET(func), | 1419 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + CSTORM_ISCSI_HQ_SIZE_OFFSET(pfid), |
| 1321 | hq_bds); | 1420 | hq_bds); |
| 1322 | 1421 | ||
| 1323 | return 0; | 1422 | return 0; |
| @@ -1327,7 +1426,7 @@ static int cnic_bnx2x_iscsi_init2(struct cnic_dev *dev, struct kwqe *kwqe) | |||
| 1327 | { | 1426 | { |
| 1328 | struct iscsi_kwqe_init2 *req2 = (struct iscsi_kwqe_init2 *) kwqe; | 1427 | struct iscsi_kwqe_init2 *req2 = (struct iscsi_kwqe_init2 *) kwqe; |
| 1329 | struct cnic_local *cp = dev->cnic_priv; | 1428 | struct cnic_local *cp = dev->cnic_priv; |
| 1330 | int func = cp->func; | 1429 | u32 pfid = cp->pfid; |
| 1331 | struct iscsi_kcqe kcqe; | 1430 | struct iscsi_kcqe kcqe; |
| 1332 | struct kcqe *cqes[1]; | 1431 | struct kcqe *cqes[1]; |
| 1333 | 1432 | ||
| @@ -1339,21 +1438,21 @@ static int cnic_bnx2x_iscsi_init2(struct cnic_dev *dev, struct kwqe *kwqe) | |||
| 1339 | } | 1438 | } |
| 1340 | 1439 | ||
| 1341 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + | 1440 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + |
| 1342 | TSTORM_ISCSI_ERROR_BITMAP_OFFSET(func), req2->error_bit_map[0]); | 1441 | TSTORM_ISCSI_ERROR_BITMAP_OFFSET(pfid), req2->error_bit_map[0]); |
| 1343 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + | 1442 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + |
| 1344 | TSTORM_ISCSI_ERROR_BITMAP_OFFSET(func) + 4, | 1443 | TSTORM_ISCSI_ERROR_BITMAP_OFFSET(pfid) + 4, |
| 1345 | req2->error_bit_map[1]); | 1444 | req2->error_bit_map[1]); |
| 1346 | 1445 | ||
| 1347 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + | 1446 | CNIC_WR16(dev, BAR_USTRORM_INTMEM + |
| 1348 | USTORM_ISCSI_CQ_SQN_SIZE_OFFSET(func), req2->max_cq_sqn); | 1447 | USTORM_ISCSI_CQ_SQN_SIZE_OFFSET(pfid), req2->max_cq_sqn); |
| 1349 | CNIC_WR(dev, BAR_USTRORM_INTMEM + | 1448 | CNIC_WR(dev, BAR_USTRORM_INTMEM + |
| 1350 | USTORM_ISCSI_ERROR_BITMAP_OFFSET(func), req2->error_bit_map[0]); | 1449 | USTORM_ISCSI_ERROR_BITMAP_OFFSET(pfid), req2->error_bit_map[0]); |
| 1351 | CNIC_WR(dev, BAR_USTRORM_INTMEM + | 1450 | CNIC_WR(dev, BAR_USTRORM_INTMEM + |
| 1352 | USTORM_ISCSI_ERROR_BITMAP_OFFSET(func) + 4, | 1451 | USTORM_ISCSI_ERROR_BITMAP_OFFSET(pfid) + 4, |
| 1353 | req2->error_bit_map[1]); | 1452 | req2->error_bit_map[1]); |
| 1354 | 1453 | ||
| 1355 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + | 1454 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + |
| 1356 | CSTORM_ISCSI_CQ_SQN_SIZE_OFFSET(func), req2->max_cq_sqn); | 1455 | CSTORM_ISCSI_CQ_SQN_SIZE_OFFSET(pfid), req2->max_cq_sqn); |
| 1357 | 1456 | ||
| 1358 | kcqe.completion_status = ISCSI_KCQE_COMPLETION_STATUS_SUCCESS; | 1457 | kcqe.completion_status = ISCSI_KCQE_COMPLETION_STATUS_SUCCESS; |
| 1359 | 1458 | ||
| @@ -1376,8 +1475,11 @@ static void cnic_free_bnx2x_conn_resc(struct cnic_dev *dev, u32 l5_cid) | |||
| 1376 | cnic_free_dma(dev, &iscsi->hq_info); | 1475 | cnic_free_dma(dev, &iscsi->hq_info); |
| 1377 | cnic_free_dma(dev, &iscsi->r2tq_info); | 1476 | cnic_free_dma(dev, &iscsi->r2tq_info); |
| 1378 | cnic_free_dma(dev, &iscsi->task_array_info); | 1477 | cnic_free_dma(dev, &iscsi->task_array_info); |
| 1478 | cnic_free_id(&cp->cid_tbl, ctx->cid); | ||
| 1479 | } else { | ||
| 1480 | cnic_free_id(&cp->fcoe_cid_tbl, ctx->cid); | ||
| 1379 | } | 1481 | } |
| 1380 | cnic_free_id(&cp->cid_tbl, ctx->cid); | 1482 | |
| 1381 | ctx->cid = 0; | 1483 | ctx->cid = 0; |
| 1382 | } | 1484 | } |
| 1383 | 1485 | ||
| @@ -1389,6 +1491,16 @@ static int cnic_alloc_bnx2x_conn_resc(struct cnic_dev *dev, u32 l5_cid) | |||
| 1389 | struct cnic_context *ctx = &cp->ctx_tbl[l5_cid]; | 1491 | struct cnic_context *ctx = &cp->ctx_tbl[l5_cid]; |
| 1390 | struct cnic_iscsi *iscsi = ctx->proto.iscsi; | 1492 | struct cnic_iscsi *iscsi = ctx->proto.iscsi; |
| 1391 | 1493 | ||
| 1494 | if (ctx->ulp_proto_id == CNIC_ULP_FCOE) { | ||
| 1495 | cid = cnic_alloc_new_id(&cp->fcoe_cid_tbl); | ||
| 1496 | if (cid == -1) { | ||
| 1497 | ret = -ENOMEM; | ||
| 1498 | goto error; | ||
| 1499 | } | ||
| 1500 | ctx->cid = cid; | ||
| 1501 | return 0; | ||
| 1502 | } | ||
| 1503 | |||
| 1392 | cid = cnic_alloc_new_id(&cp->cid_tbl); | 1504 | cid = cnic_alloc_new_id(&cp->cid_tbl); |
| 1393 | if (cid == -1) { | 1505 | if (cid == -1) { |
| 1394 | ret = -ENOMEM; | 1506 | ret = -ENOMEM; |
| @@ -1461,7 +1573,7 @@ static int cnic_setup_bnx2x_ctx(struct cnic_dev *dev, struct kwqe *wqes[], | |||
| 1461 | struct cnic_context *ctx = &cp->ctx_tbl[req1->iscsi_conn_id]; | 1573 | struct cnic_context *ctx = &cp->ctx_tbl[req1->iscsi_conn_id]; |
| 1462 | struct cnic_iscsi *iscsi = ctx->proto.iscsi; | 1574 | struct cnic_iscsi *iscsi = ctx->proto.iscsi; |
| 1463 | u32 cid = ctx->cid; | 1575 | u32 cid = ctx->cid; |
| 1464 | u32 hw_cid = BNX2X_HW_CID(cid, cp->func); | 1576 | u32 hw_cid = BNX2X_HW_CID(cp, cid); |
| 1465 | struct iscsi_context *ictx; | 1577 | struct iscsi_context *ictx; |
| 1466 | struct regpair context_addr; | 1578 | struct regpair context_addr; |
| 1467 | int i, j, n = 2, n_max; | 1579 | int i, j, n = 2, n_max; |
| @@ -1527,8 +1639,10 @@ static int cnic_setup_bnx2x_ctx(struct cnic_dev *dev, struct kwqe *wqes[], | |||
| 1527 | ictx->tstorm_st_context.tcp.cwnd = 0x5A8; | 1639 | ictx->tstorm_st_context.tcp.cwnd = 0x5A8; |
| 1528 | ictx->tstorm_st_context.tcp.flags2 |= | 1640 | ictx->tstorm_st_context.tcp.flags2 |= |
| 1529 | TSTORM_TCP_ST_CONTEXT_SECTION_DA_EN; | 1641 | TSTORM_TCP_ST_CONTEXT_SECTION_DA_EN; |
| 1642 | ictx->tstorm_st_context.tcp.ooo_support_mode = | ||
| 1643 | TCP_TSTORM_OOO_DROP_AND_PROC_ACK; | ||
| 1530 | 1644 | ||
| 1531 | ictx->timers_context.flags |= ISCSI_TIMERS_BLOCK_CONTEXT_CONN_VALID_FLG; | 1645 | ictx->timers_context.flags |= TIMERS_BLOCK_CONTEXT_CONN_VALID_FLG; |
| 1532 | 1646 | ||
| 1533 | ictx->ustorm_st_context.ring.rq.pbl_base.lo = | 1647 | ictx->ustorm_st_context.ring.rq.pbl_base.lo = |
| 1534 | req2->rq_page_table_addr_lo; | 1648 | req2->rq_page_table_addr_lo; |
| @@ -1627,10 +1741,11 @@ static int cnic_bnx2x_iscsi_ofld1(struct cnic_dev *dev, struct kwqe *wqes[], | |||
| 1627 | struct iscsi_kwqe_conn_offload1 *req1; | 1741 | struct iscsi_kwqe_conn_offload1 *req1; |
| 1628 | struct iscsi_kwqe_conn_offload2 *req2; | 1742 | struct iscsi_kwqe_conn_offload2 *req2; |
| 1629 | struct cnic_local *cp = dev->cnic_priv; | 1743 | struct cnic_local *cp = dev->cnic_priv; |
| 1744 | struct cnic_context *ctx; | ||
| 1630 | struct iscsi_kcqe kcqe; | 1745 | struct iscsi_kcqe kcqe; |
| 1631 | struct kcqe *cqes[1]; | 1746 | struct kcqe *cqes[1]; |
| 1632 | u32 l5_cid; | 1747 | u32 l5_cid; |
| 1633 | int ret; | 1748 | int ret = 0; |
| 1634 | 1749 | ||
| 1635 | if (num < 2) { | 1750 | if (num < 2) { |
| 1636 | *work = num; | 1751 | *work = num; |
| @@ -1643,7 +1758,7 @@ static int cnic_bnx2x_iscsi_ofld1(struct cnic_dev *dev, struct kwqe *wqes[], | |||
| 1643 | *work = num; | 1758 | *work = num; |
| 1644 | return -EINVAL; | 1759 | return -EINVAL; |
| 1645 | } | 1760 | } |
| 1646 | *work = 2 + req2->num_additional_wqes;; | 1761 | *work = 2 + req2->num_additional_wqes; |
| 1647 | 1762 | ||
| 1648 | l5_cid = req1->iscsi_conn_id; | 1763 | l5_cid = req1->iscsi_conn_id; |
| 1649 | if (l5_cid >= MAX_ISCSI_TBL_SZ) | 1764 | if (l5_cid >= MAX_ISCSI_TBL_SZ) |
| @@ -1654,9 +1769,15 @@ static int cnic_bnx2x_iscsi_ofld1(struct cnic_dev *dev, struct kwqe *wqes[], | |||
| 1654 | kcqe.iscsi_conn_id = l5_cid; | 1769 | kcqe.iscsi_conn_id = l5_cid; |
| 1655 | kcqe.completion_status = ISCSI_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAILURE; | 1770 | kcqe.completion_status = ISCSI_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAILURE; |
| 1656 | 1771 | ||
| 1772 | ctx = &cp->ctx_tbl[l5_cid]; | ||
| 1773 | if (test_bit(CTX_FL_OFFLD_START, &ctx->ctx_flags)) { | ||
| 1774 | kcqe.completion_status = | ||
| 1775 | ISCSI_KCQE_COMPLETION_STATUS_CID_BUSY; | ||
| 1776 | goto done; | ||
| 1777 | } | ||
| 1778 | |||
| 1657 | if (atomic_inc_return(&cp->iscsi_conn) > dev->max_iscsi_conn) { | 1779 | if (atomic_inc_return(&cp->iscsi_conn) > dev->max_iscsi_conn) { |
| 1658 | atomic_dec(&cp->iscsi_conn); | 1780 | atomic_dec(&cp->iscsi_conn); |
| 1659 | ret = 0; | ||
| 1660 | goto done; | 1781 | goto done; |
| 1661 | } | 1782 | } |
| 1662 | ret = cnic_alloc_bnx2x_conn_resc(dev, l5_cid); | 1783 | ret = cnic_alloc_bnx2x_conn_resc(dev, l5_cid); |
| @@ -1673,8 +1794,7 @@ static int cnic_bnx2x_iscsi_ofld1(struct cnic_dev *dev, struct kwqe *wqes[], | |||
| 1673 | } | 1794 | } |
| 1674 | 1795 | ||
| 1675 | kcqe.completion_status = ISCSI_KCQE_COMPLETION_STATUS_SUCCESS; | 1796 | kcqe.completion_status = ISCSI_KCQE_COMPLETION_STATUS_SUCCESS; |
| 1676 | kcqe.iscsi_conn_context_id = BNX2X_HW_CID(cp->ctx_tbl[l5_cid].cid, | 1797 | kcqe.iscsi_conn_context_id = BNX2X_HW_CID(cp, cp->ctx_tbl[l5_cid].cid); |
| 1677 | cp->func); | ||
| 1678 | 1798 | ||
| 1679 | done: | 1799 | done: |
| 1680 | cqes[0] = (struct kcqe *) &kcqe; | 1800 | cqes[0] = (struct kcqe *) &kcqe; |
| @@ -1707,40 +1827,62 @@ static int cnic_bnx2x_iscsi_update(struct cnic_dev *dev, struct kwqe *kwqe) | |||
| 1707 | return ret; | 1827 | return ret; |
| 1708 | } | 1828 | } |
| 1709 | 1829 | ||
| 1830 | static int cnic_bnx2x_destroy_ramrod(struct cnic_dev *dev, u32 l5_cid) | ||
| 1831 | { | ||
| 1832 | struct cnic_local *cp = dev->cnic_priv; | ||
| 1833 | struct cnic_context *ctx = &cp->ctx_tbl[l5_cid]; | ||
| 1834 | union l5cm_specific_data l5_data; | ||
| 1835 | int ret; | ||
| 1836 | u32 hw_cid; | ||
| 1837 | |||
| 1838 | init_waitqueue_head(&ctx->waitq); | ||
| 1839 | ctx->wait_cond = 0; | ||
| 1840 | memset(&l5_data, 0, sizeof(l5_data)); | ||
| 1841 | hw_cid = BNX2X_HW_CID(cp, ctx->cid); | ||
| 1842 | |||
| 1843 | ret = cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_COMMON_CFC_DEL, | ||
| 1844 | hw_cid, NONE_CONNECTION_TYPE, &l5_data); | ||
| 1845 | |||
| 1846 | if (ret == 0) | ||
| 1847 | wait_event(ctx->waitq, ctx->wait_cond); | ||
| 1848 | |||
| 1849 | return ret; | ||
| 1850 | } | ||
| 1851 | |||
| 1710 | static int cnic_bnx2x_iscsi_destroy(struct cnic_dev *dev, struct kwqe *kwqe) | 1852 | static int cnic_bnx2x_iscsi_destroy(struct cnic_dev *dev, struct kwqe *kwqe) |
| 1711 | { | 1853 | { |
| 1712 | struct cnic_local *cp = dev->cnic_priv; | 1854 | struct cnic_local *cp = dev->cnic_priv; |
| 1713 | struct iscsi_kwqe_conn_destroy *req = | 1855 | struct iscsi_kwqe_conn_destroy *req = |
| 1714 | (struct iscsi_kwqe_conn_destroy *) kwqe; | 1856 | (struct iscsi_kwqe_conn_destroy *) kwqe; |
| 1715 | union l5cm_specific_data l5_data; | ||
| 1716 | u32 l5_cid = req->reserved0; | 1857 | u32 l5_cid = req->reserved0; |
| 1717 | struct cnic_context *ctx = &cp->ctx_tbl[l5_cid]; | 1858 | struct cnic_context *ctx = &cp->ctx_tbl[l5_cid]; |
| 1718 | int ret = 0; | 1859 | int ret = 0; |
| 1719 | struct iscsi_kcqe kcqe; | 1860 | struct iscsi_kcqe kcqe; |
| 1720 | struct kcqe *cqes[1]; | 1861 | struct kcqe *cqes[1]; |
| 1721 | 1862 | ||
| 1722 | if (!(ctx->ctx_flags & CTX_FL_OFFLD_START)) | 1863 | if (!test_bit(CTX_FL_OFFLD_START, &ctx->ctx_flags)) |
| 1723 | goto skip_cfc_delete; | 1864 | goto skip_cfc_delete; |
| 1724 | 1865 | ||
| 1725 | while (!time_after(jiffies, ctx->timestamp + (2 * HZ))) | 1866 | if (!time_after(jiffies, ctx->timestamp + (2 * HZ))) { |
| 1726 | msleep(250); | 1867 | unsigned long delta = ctx->timestamp + (2 * HZ) - jiffies; |
| 1727 | 1868 | ||
| 1728 | init_waitqueue_head(&ctx->waitq); | 1869 | if (delta > (2 * HZ)) |
| 1729 | ctx->wait_cond = 0; | 1870 | delta = 0; |
| 1730 | memset(&l5_data, 0, sizeof(l5_data)); | 1871 | |
| 1731 | ret = cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_CFC_DEL, | 1872 | set_bit(CTX_FL_DELETE_WAIT, &ctx->ctx_flags); |
| 1732 | req->context_id, | 1873 | queue_delayed_work(cnic_wq, &cp->delete_task, delta); |
| 1733 | ETH_CONNECTION_TYPE | | 1874 | goto destroy_reply; |
| 1734 | (1 << SPE_HDR_COMMON_RAMROD_SHIFT), | 1875 | } |
| 1735 | &l5_data); | 1876 | |
| 1736 | if (ret == 0) | 1877 | ret = cnic_bnx2x_destroy_ramrod(dev, l5_cid); |
| 1737 | wait_event(ctx->waitq, ctx->wait_cond); | ||
| 1738 | 1878 | ||
| 1739 | skip_cfc_delete: | 1879 | skip_cfc_delete: |
| 1740 | cnic_free_bnx2x_conn_resc(dev, l5_cid); | 1880 | cnic_free_bnx2x_conn_resc(dev, l5_cid); |
| 1741 | 1881 | ||
| 1742 | atomic_dec(&cp->iscsi_conn); | 1882 | atomic_dec(&cp->iscsi_conn); |
| 1883 | clear_bit(CTX_FL_OFFLD_START, &ctx->ctx_flags); | ||
| 1743 | 1884 | ||
| 1885 | destroy_reply: | ||
| 1744 | memset(&kcqe, 0, sizeof(kcqe)); | 1886 | memset(&kcqe, 0, sizeof(kcqe)); |
| 1745 | kcqe.op_code = ISCSI_KCQE_OPCODE_DESTROY_CONN; | 1887 | kcqe.op_code = ISCSI_KCQE_OPCODE_DESTROY_CONN; |
| 1746 | kcqe.iscsi_conn_id = l5_cid; | 1888 | kcqe.iscsi_conn_id = l5_cid; |
| @@ -1805,37 +1947,37 @@ static void cnic_init_storm_conn_bufs(struct cnic_dev *dev, | |||
| 1805 | static void cnic_init_bnx2x_mac(struct cnic_dev *dev) | 1947 | static void cnic_init_bnx2x_mac(struct cnic_dev *dev) |
| 1806 | { | 1948 | { |
| 1807 | struct cnic_local *cp = dev->cnic_priv; | 1949 | struct cnic_local *cp = dev->cnic_priv; |
| 1808 | int func = CNIC_FUNC(cp); | 1950 | u32 pfid = cp->pfid; |
| 1809 | u8 *mac = dev->mac_addr; | 1951 | u8 *mac = dev->mac_addr; |
| 1810 | 1952 | ||
| 1811 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + | 1953 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + |
| 1812 | XSTORM_ISCSI_LOCAL_MAC_ADDR0_OFFSET(func), mac[0]); | 1954 | XSTORM_ISCSI_LOCAL_MAC_ADDR0_OFFSET(pfid), mac[0]); |
| 1813 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + | 1955 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + |
| 1814 | XSTORM_ISCSI_LOCAL_MAC_ADDR1_OFFSET(func), mac[1]); | 1956 | XSTORM_ISCSI_LOCAL_MAC_ADDR1_OFFSET(pfid), mac[1]); |
| 1815 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + | 1957 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + |
| 1816 | XSTORM_ISCSI_LOCAL_MAC_ADDR2_OFFSET(func), mac[2]); | 1958 | XSTORM_ISCSI_LOCAL_MAC_ADDR2_OFFSET(pfid), mac[2]); |
| 1817 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + | 1959 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + |
| 1818 | XSTORM_ISCSI_LOCAL_MAC_ADDR3_OFFSET(func), mac[3]); | 1960 | XSTORM_ISCSI_LOCAL_MAC_ADDR3_OFFSET(pfid), mac[3]); |
| 1819 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + | 1961 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + |
| 1820 | XSTORM_ISCSI_LOCAL_MAC_ADDR4_OFFSET(func), mac[4]); | 1962 | XSTORM_ISCSI_LOCAL_MAC_ADDR4_OFFSET(pfid), mac[4]); |
| 1821 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + | 1963 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + |
| 1822 | XSTORM_ISCSI_LOCAL_MAC_ADDR5_OFFSET(func), mac[5]); | 1964 | XSTORM_ISCSI_LOCAL_MAC_ADDR5_OFFSET(pfid), mac[5]); |
| 1823 | 1965 | ||
| 1824 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + | 1966 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + |
| 1825 | TSTORM_ISCSI_TCP_VARS_LSB_LOCAL_MAC_ADDR_OFFSET(func), mac[5]); | 1967 | TSTORM_ISCSI_TCP_VARS_LSB_LOCAL_MAC_ADDR_OFFSET(pfid), mac[5]); |
| 1826 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + | 1968 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + |
| 1827 | TSTORM_ISCSI_TCP_VARS_LSB_LOCAL_MAC_ADDR_OFFSET(func) + 1, | 1969 | TSTORM_ISCSI_TCP_VARS_LSB_LOCAL_MAC_ADDR_OFFSET(pfid) + 1, |
| 1828 | mac[4]); | 1970 | mac[4]); |
| 1829 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + | 1971 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + |
| 1830 | TSTORM_ISCSI_TCP_VARS_MSB_LOCAL_MAC_ADDR_OFFSET(func), mac[3]); | 1972 | TSTORM_ISCSI_TCP_VARS_MSB_LOCAL_MAC_ADDR_OFFSET(pfid), mac[3]); |
| 1831 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + | 1973 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + |
| 1832 | TSTORM_ISCSI_TCP_VARS_MSB_LOCAL_MAC_ADDR_OFFSET(func) + 1, | 1974 | TSTORM_ISCSI_TCP_VARS_MSB_LOCAL_MAC_ADDR_OFFSET(pfid) + 1, |
| 1833 | mac[2]); | 1975 | mac[2]); |
| 1834 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + | 1976 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + |
| 1835 | TSTORM_ISCSI_TCP_VARS_MSB_LOCAL_MAC_ADDR_OFFSET(func) + 2, | 1977 | TSTORM_ISCSI_TCP_VARS_MSB_LOCAL_MAC_ADDR_OFFSET(pfid) + 2, |
| 1836 | mac[1]); | 1978 | mac[1]); |
| 1837 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + | 1979 | CNIC_WR8(dev, BAR_TSTRORM_INTMEM + |
| 1838 | TSTORM_ISCSI_TCP_VARS_MSB_LOCAL_MAC_ADDR_OFFSET(func) + 3, | 1980 | TSTORM_ISCSI_TCP_VARS_MSB_LOCAL_MAC_ADDR_OFFSET(pfid) + 3, |
| 1839 | mac[0]); | 1981 | mac[0]); |
| 1840 | } | 1982 | } |
| 1841 | 1983 | ||
| @@ -1851,10 +1993,10 @@ static void cnic_bnx2x_set_tcp_timestamp(struct cnic_dev *dev, int tcp_ts) | |||
| 1851 | } | 1993 | } |
| 1852 | 1994 | ||
| 1853 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + | 1995 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + |
| 1854 | XSTORM_ISCSI_TCP_VARS_FLAGS_OFFSET(cp->func), xstorm_flags); | 1996 | XSTORM_ISCSI_TCP_VARS_FLAGS_OFFSET(cp->pfid), xstorm_flags); |
| 1855 | 1997 | ||
| 1856 | CNIC_WR16(dev, BAR_TSTRORM_INTMEM + | 1998 | CNIC_WR16(dev, BAR_TSTRORM_INTMEM + |
| 1857 | TSTORM_ISCSI_TCP_VARS_FLAGS_OFFSET(cp->func), tstorm_flags); | 1999 | TSTORM_ISCSI_TCP_VARS_FLAGS_OFFSET(cp->pfid), tstorm_flags); |
| 1858 | } | 2000 | } |
| 1859 | 2001 | ||
| 1860 | static int cnic_bnx2x_connect(struct cnic_dev *dev, struct kwqe *wqes[], | 2002 | static int cnic_bnx2x_connect(struct cnic_dev *dev, struct kwqe *wqes[], |
| @@ -1929,7 +2071,7 @@ static int cnic_bnx2x_connect(struct cnic_dev *dev, struct kwqe *wqes[], | |||
| 1929 | cnic_init_storm_conn_bufs(dev, kwqe1, kwqe3, conn_buf); | 2071 | cnic_init_storm_conn_bufs(dev, kwqe1, kwqe3, conn_buf); |
| 1930 | 2072 | ||
| 1931 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + | 2073 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + |
| 1932 | XSTORM_ISCSI_LOCAL_VLAN_OFFSET(cp->func), csk->vlan_id); | 2074 | XSTORM_ISCSI_LOCAL_VLAN_OFFSET(cp->pfid), csk->vlan_id); |
| 1933 | 2075 | ||
| 1934 | cnic_bnx2x_set_tcp_timestamp(dev, | 2076 | cnic_bnx2x_set_tcp_timestamp(dev, |
| 1935 | kwqe1->tcp_flags & L4_KWQ_CONNECT_REQ1_TIME_STAMP); | 2077 | kwqe1->tcp_flags & L4_KWQ_CONNECT_REQ1_TIME_STAMP); |
| @@ -1937,7 +2079,7 @@ static int cnic_bnx2x_connect(struct cnic_dev *dev, struct kwqe *wqes[], | |||
| 1937 | ret = cnic_submit_kwqe_16(dev, L5CM_RAMROD_CMD_ID_TCP_CONNECT, | 2079 | ret = cnic_submit_kwqe_16(dev, L5CM_RAMROD_CMD_ID_TCP_CONNECT, |
| 1938 | kwqe1->cid, ISCSI_CONNECTION_TYPE, &l5_data); | 2080 | kwqe1->cid, ISCSI_CONNECTION_TYPE, &l5_data); |
| 1939 | if (!ret) | 2081 | if (!ret) |
| 1940 | ctx->ctx_flags |= CTX_FL_OFFLD_START; | 2082 | set_bit(CTX_FL_OFFLD_START, &ctx->ctx_flags); |
| 1941 | 2083 | ||
| 1942 | return ret; | 2084 | return ret; |
| 1943 | } | 2085 | } |
| @@ -1995,8 +2137,306 @@ static int cnic_bnx2x_update_pg(struct cnic_dev *dev, struct kwqe *kwqe) | |||
| 1995 | return 0; | 2137 | return 0; |
| 1996 | } | 2138 | } |
| 1997 | 2139 | ||
| 1998 | static int cnic_submit_bnx2x_kwqes(struct cnic_dev *dev, struct kwqe *wqes[], | 2140 | static int cnic_bnx2x_fcoe_stat(struct cnic_dev *dev, struct kwqe *kwqe) |
| 1999 | u32 num_wqes) | 2141 | { |
| 2142 | struct fcoe_kwqe_stat *req; | ||
| 2143 | struct fcoe_stat_ramrod_params *fcoe_stat; | ||
| 2144 | union l5cm_specific_data l5_data; | ||
| 2145 | struct cnic_local *cp = dev->cnic_priv; | ||
| 2146 | int ret; | ||
| 2147 | u32 cid; | ||
| 2148 | |||
| 2149 | req = (struct fcoe_kwqe_stat *) kwqe; | ||
| 2150 | cid = BNX2X_HW_CID(cp, cp->fcoe_init_cid); | ||
| 2151 | |||
| 2152 | fcoe_stat = cnic_get_kwqe_16_data(cp, BNX2X_FCOE_L5_CID_BASE, &l5_data); | ||
| 2153 | if (!fcoe_stat) | ||
| 2154 | return -ENOMEM; | ||
| 2155 | |||
| 2156 | memset(fcoe_stat, 0, sizeof(*fcoe_stat)); | ||
| 2157 | memcpy(&fcoe_stat->stat_kwqe, req, sizeof(*req)); | ||
| 2158 | |||
| 2159 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_STAT, cid, | ||
| 2160 | FCOE_CONNECTION_TYPE, &l5_data); | ||
| 2161 | return ret; | ||
| 2162 | } | ||
| 2163 | |||
| 2164 | static int cnic_bnx2x_fcoe_init1(struct cnic_dev *dev, struct kwqe *wqes[], | ||
| 2165 | u32 num, int *work) | ||
| 2166 | { | ||
| 2167 | int ret; | ||
| 2168 | struct cnic_local *cp = dev->cnic_priv; | ||
| 2169 | u32 cid; | ||
| 2170 | struct fcoe_init_ramrod_params *fcoe_init; | ||
| 2171 | struct fcoe_kwqe_init1 *req1; | ||
| 2172 | struct fcoe_kwqe_init2 *req2; | ||
| 2173 | struct fcoe_kwqe_init3 *req3; | ||
| 2174 | union l5cm_specific_data l5_data; | ||
| 2175 | |||
| 2176 | if (num < 3) { | ||
| 2177 | *work = num; | ||
| 2178 | return -EINVAL; | ||
| 2179 | } | ||
| 2180 | req1 = (struct fcoe_kwqe_init1 *) wqes[0]; | ||
| 2181 | req2 = (struct fcoe_kwqe_init2 *) wqes[1]; | ||
| 2182 | req3 = (struct fcoe_kwqe_init3 *) wqes[2]; | ||
| 2183 | if (req2->hdr.op_code != FCOE_KWQE_OPCODE_INIT2) { | ||
| 2184 | *work = 1; | ||
| 2185 | return -EINVAL; | ||
| 2186 | } | ||
| 2187 | if (req3->hdr.op_code != FCOE_KWQE_OPCODE_INIT3) { | ||
| 2188 | *work = 2; | ||
| 2189 | return -EINVAL; | ||
| 2190 | } | ||
| 2191 | |||
| 2192 | if (sizeof(*fcoe_init) > CNIC_KWQ16_DATA_SIZE) { | ||
| 2193 | netdev_err(dev->netdev, "fcoe_init size too big\n"); | ||
| 2194 | return -ENOMEM; | ||
| 2195 | } | ||
| 2196 | fcoe_init = cnic_get_kwqe_16_data(cp, BNX2X_FCOE_L5_CID_BASE, &l5_data); | ||
| 2197 | if (!fcoe_init) | ||
| 2198 | return -ENOMEM; | ||
| 2199 | |||
| 2200 | memset(fcoe_init, 0, sizeof(*fcoe_init)); | ||
| 2201 | memcpy(&fcoe_init->init_kwqe1, req1, sizeof(*req1)); | ||
| 2202 | memcpy(&fcoe_init->init_kwqe2, req2, sizeof(*req2)); | ||
| 2203 | memcpy(&fcoe_init->init_kwqe3, req3, sizeof(*req3)); | ||
| 2204 | fcoe_init->eq_addr.lo = cp->kcq2.dma.pg_map_arr[0] & 0xffffffff; | ||
| 2205 | fcoe_init->eq_addr.hi = (u64) cp->kcq2.dma.pg_map_arr[0] >> 32; | ||
| 2206 | fcoe_init->eq_next_page_addr.lo = | ||
| 2207 | cp->kcq2.dma.pg_map_arr[1] & 0xffffffff; | ||
| 2208 | fcoe_init->eq_next_page_addr.hi = | ||
| 2209 | (u64) cp->kcq2.dma.pg_map_arr[1] >> 32; | ||
| 2210 | |||
| 2211 | fcoe_init->sb_num = cp->status_blk_num; | ||
| 2212 | fcoe_init->eq_prod = MAX_KCQ_IDX; | ||
| 2213 | fcoe_init->sb_id = HC_INDEX_FCOE_EQ_CONS; | ||
| 2214 | cp->kcq2.sw_prod_idx = 0; | ||
| 2215 | |||
| 2216 | cid = BNX2X_HW_CID(cp, cp->fcoe_init_cid); | ||
| 2217 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_INIT, cid, | ||
| 2218 | FCOE_CONNECTION_TYPE, &l5_data); | ||
| 2219 | *work = 3; | ||
| 2220 | return ret; | ||
| 2221 | } | ||
| 2222 | |||
| 2223 | static int cnic_bnx2x_fcoe_ofld1(struct cnic_dev *dev, struct kwqe *wqes[], | ||
| 2224 | u32 num, int *work) | ||
| 2225 | { | ||
| 2226 | int ret = 0; | ||
| 2227 | u32 cid = -1, l5_cid; | ||
| 2228 | struct cnic_local *cp = dev->cnic_priv; | ||
| 2229 | struct fcoe_kwqe_conn_offload1 *req1; | ||
| 2230 | struct fcoe_kwqe_conn_offload2 *req2; | ||
| 2231 | struct fcoe_kwqe_conn_offload3 *req3; | ||
| 2232 | struct fcoe_kwqe_conn_offload4 *req4; | ||
| 2233 | struct fcoe_conn_offload_ramrod_params *fcoe_offload; | ||
| 2234 | struct cnic_context *ctx; | ||
| 2235 | struct fcoe_context *fctx; | ||
| 2236 | struct regpair ctx_addr; | ||
| 2237 | union l5cm_specific_data l5_data; | ||
| 2238 | struct fcoe_kcqe kcqe; | ||
| 2239 | struct kcqe *cqes[1]; | ||
| 2240 | |||
| 2241 | if (num < 4) { | ||
| 2242 | *work = num; | ||
| 2243 | return -EINVAL; | ||
| 2244 | } | ||
| 2245 | req1 = (struct fcoe_kwqe_conn_offload1 *) wqes[0]; | ||
| 2246 | req2 = (struct fcoe_kwqe_conn_offload2 *) wqes[1]; | ||
| 2247 | req3 = (struct fcoe_kwqe_conn_offload3 *) wqes[2]; | ||
| 2248 | req4 = (struct fcoe_kwqe_conn_offload4 *) wqes[3]; | ||
| 2249 | |||
| 2250 | *work = 4; | ||
| 2251 | |||
| 2252 | l5_cid = req1->fcoe_conn_id; | ||
| 2253 | if (l5_cid >= BNX2X_FCOE_NUM_CONNECTIONS) | ||
| 2254 | goto err_reply; | ||
| 2255 | |||
| 2256 | l5_cid += BNX2X_FCOE_L5_CID_BASE; | ||
| 2257 | |||
| 2258 | ctx = &cp->ctx_tbl[l5_cid]; | ||
| 2259 | if (test_bit(CTX_FL_OFFLD_START, &ctx->ctx_flags)) | ||
| 2260 | goto err_reply; | ||
| 2261 | |||
| 2262 | ret = cnic_alloc_bnx2x_conn_resc(dev, l5_cid); | ||
| 2263 | if (ret) { | ||
| 2264 | ret = 0; | ||
| 2265 | goto err_reply; | ||
| 2266 | } | ||
| 2267 | cid = ctx->cid; | ||
| 2268 | |||
| 2269 | fctx = cnic_get_bnx2x_ctx(dev, cid, 1, &ctx_addr); | ||
| 2270 | if (fctx) { | ||
| 2271 | u32 hw_cid = BNX2X_HW_CID(cp, cid); | ||
| 2272 | u32 val; | ||
| 2273 | |||
| 2274 | val = CDU_RSRVD_VALUE_TYPE_A(hw_cid, CDU_REGION_NUMBER_XCM_AG, | ||
| 2275 | FCOE_CONNECTION_TYPE); | ||
| 2276 | fctx->xstorm_ag_context.cdu_reserved = val; | ||
| 2277 | val = CDU_RSRVD_VALUE_TYPE_A(hw_cid, CDU_REGION_NUMBER_UCM_AG, | ||
| 2278 | FCOE_CONNECTION_TYPE); | ||
| 2279 | fctx->ustorm_ag_context.cdu_usage = val; | ||
| 2280 | } | ||
| 2281 | if (sizeof(*fcoe_offload) > CNIC_KWQ16_DATA_SIZE) { | ||
| 2282 | netdev_err(dev->netdev, "fcoe_offload size too big\n"); | ||
| 2283 | goto err_reply; | ||
| 2284 | } | ||
| 2285 | fcoe_offload = cnic_get_kwqe_16_data(cp, l5_cid, &l5_data); | ||
| 2286 | if (!fcoe_offload) | ||
| 2287 | goto err_reply; | ||
| 2288 | |||
| 2289 | memset(fcoe_offload, 0, sizeof(*fcoe_offload)); | ||
| 2290 | memcpy(&fcoe_offload->offload_kwqe1, req1, sizeof(*req1)); | ||
| 2291 | memcpy(&fcoe_offload->offload_kwqe2, req2, sizeof(*req2)); | ||
| 2292 | memcpy(&fcoe_offload->offload_kwqe3, req3, sizeof(*req3)); | ||
| 2293 | memcpy(&fcoe_offload->offload_kwqe4, req4, sizeof(*req4)); | ||
| 2294 | |||
| 2295 | cid = BNX2X_HW_CID(cp, cid); | ||
| 2296 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_OFFLOAD_CONN, cid, | ||
| 2297 | FCOE_CONNECTION_TYPE, &l5_data); | ||
| 2298 | if (!ret) | ||
| 2299 | set_bit(CTX_FL_OFFLD_START, &ctx->ctx_flags); | ||
| 2300 | |||
| 2301 | return ret; | ||
| 2302 | |||
| 2303 | err_reply: | ||
| 2304 | if (cid != -1) | ||
| 2305 | cnic_free_bnx2x_conn_resc(dev, l5_cid); | ||
| 2306 | |||
| 2307 | memset(&kcqe, 0, sizeof(kcqe)); | ||
| 2308 | kcqe.op_code = FCOE_KCQE_OPCODE_OFFLOAD_CONN; | ||
| 2309 | kcqe.fcoe_conn_id = req1->fcoe_conn_id; | ||
| 2310 | kcqe.completion_status = FCOE_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAILURE; | ||
| 2311 | |||
| 2312 | cqes[0] = (struct kcqe *) &kcqe; | ||
| 2313 | cnic_reply_bnx2x_kcqes(dev, CNIC_ULP_FCOE, cqes, 1); | ||
| 2314 | return ret; | ||
| 2315 | } | ||
| 2316 | |||
| 2317 | static int cnic_bnx2x_fcoe_enable(struct cnic_dev *dev, struct kwqe *kwqe) | ||
| 2318 | { | ||
| 2319 | struct fcoe_kwqe_conn_enable_disable *req; | ||
| 2320 | struct fcoe_conn_enable_disable_ramrod_params *fcoe_enable; | ||
| 2321 | union l5cm_specific_data l5_data; | ||
| 2322 | int ret; | ||
| 2323 | u32 cid, l5_cid; | ||
| 2324 | struct cnic_local *cp = dev->cnic_priv; | ||
| 2325 | |||
| 2326 | req = (struct fcoe_kwqe_conn_enable_disable *) kwqe; | ||
| 2327 | cid = req->context_id; | ||
| 2328 | l5_cid = req->conn_id + BNX2X_FCOE_L5_CID_BASE; | ||
| 2329 | |||
| 2330 | if (sizeof(*fcoe_enable) > CNIC_KWQ16_DATA_SIZE) { | ||
| 2331 | netdev_err(dev->netdev, "fcoe_enable size too big\n"); | ||
| 2332 | return -ENOMEM; | ||
| 2333 | } | ||
| 2334 | fcoe_enable = cnic_get_kwqe_16_data(cp, l5_cid, &l5_data); | ||
| 2335 | if (!fcoe_enable) | ||
| 2336 | return -ENOMEM; | ||
| 2337 | |||
| 2338 | memset(fcoe_enable, 0, sizeof(*fcoe_enable)); | ||
| 2339 | memcpy(&fcoe_enable->enable_disable_kwqe, req, sizeof(*req)); | ||
| 2340 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_ENABLE_CONN, cid, | ||
| 2341 | FCOE_CONNECTION_TYPE, &l5_data); | ||
| 2342 | return ret; | ||
| 2343 | } | ||
| 2344 | |||
| 2345 | static int cnic_bnx2x_fcoe_disable(struct cnic_dev *dev, struct kwqe *kwqe) | ||
| 2346 | { | ||
| 2347 | struct fcoe_kwqe_conn_enable_disable *req; | ||
| 2348 | struct fcoe_conn_enable_disable_ramrod_params *fcoe_disable; | ||
| 2349 | union l5cm_specific_data l5_data; | ||
| 2350 | int ret; | ||
| 2351 | u32 cid, l5_cid; | ||
| 2352 | struct cnic_local *cp = dev->cnic_priv; | ||
| 2353 | |||
| 2354 | req = (struct fcoe_kwqe_conn_enable_disable *) kwqe; | ||
| 2355 | cid = req->context_id; | ||
| 2356 | l5_cid = req->conn_id; | ||
| 2357 | if (l5_cid >= BNX2X_FCOE_NUM_CONNECTIONS) | ||
| 2358 | return -EINVAL; | ||
| 2359 | |||
| 2360 | l5_cid += BNX2X_FCOE_L5_CID_BASE; | ||
| 2361 | |||
| 2362 | if (sizeof(*fcoe_disable) > CNIC_KWQ16_DATA_SIZE) { | ||
| 2363 | netdev_err(dev->netdev, "fcoe_disable size too big\n"); | ||
| 2364 | return -ENOMEM; | ||
| 2365 | } | ||
| 2366 | fcoe_disable = cnic_get_kwqe_16_data(cp, l5_cid, &l5_data); | ||
| 2367 | if (!fcoe_disable) | ||
| 2368 | return -ENOMEM; | ||
| 2369 | |||
| 2370 | memset(fcoe_disable, 0, sizeof(*fcoe_disable)); | ||
| 2371 | memcpy(&fcoe_disable->enable_disable_kwqe, req, sizeof(*req)); | ||
| 2372 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_DISABLE_CONN, cid, | ||
| 2373 | FCOE_CONNECTION_TYPE, &l5_data); | ||
| 2374 | return ret; | ||
| 2375 | } | ||
| 2376 | |||
| 2377 | static int cnic_bnx2x_fcoe_destroy(struct cnic_dev *dev, struct kwqe *kwqe) | ||
| 2378 | { | ||
| 2379 | struct fcoe_kwqe_conn_destroy *req; | ||
| 2380 | union l5cm_specific_data l5_data; | ||
| 2381 | int ret; | ||
| 2382 | u32 cid, l5_cid; | ||
| 2383 | struct cnic_local *cp = dev->cnic_priv; | ||
| 2384 | struct cnic_context *ctx; | ||
| 2385 | struct fcoe_kcqe kcqe; | ||
| 2386 | struct kcqe *cqes[1]; | ||
| 2387 | |||
| 2388 | req = (struct fcoe_kwqe_conn_destroy *) kwqe; | ||
| 2389 | cid = req->context_id; | ||
| 2390 | l5_cid = req->conn_id; | ||
| 2391 | if (l5_cid >= BNX2X_FCOE_NUM_CONNECTIONS) | ||
| 2392 | return -EINVAL; | ||
| 2393 | |||
| 2394 | l5_cid += BNX2X_FCOE_L5_CID_BASE; | ||
| 2395 | |||
| 2396 | ctx = &cp->ctx_tbl[l5_cid]; | ||
| 2397 | |||
| 2398 | init_waitqueue_head(&ctx->waitq); | ||
| 2399 | ctx->wait_cond = 0; | ||
| 2400 | |||
| 2401 | memset(&l5_data, 0, sizeof(l5_data)); | ||
| 2402 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_TERMINATE_CONN, cid, | ||
| 2403 | FCOE_CONNECTION_TYPE, &l5_data); | ||
| 2404 | if (ret == 0) { | ||
| 2405 | wait_event(ctx->waitq, ctx->wait_cond); | ||
| 2406 | set_bit(CTX_FL_DELETE_WAIT, &ctx->ctx_flags); | ||
| 2407 | queue_delayed_work(cnic_wq, &cp->delete_task, | ||
| 2408 | msecs_to_jiffies(2000)); | ||
| 2409 | } | ||
| 2410 | |||
| 2411 | memset(&kcqe, 0, sizeof(kcqe)); | ||
| 2412 | kcqe.op_code = FCOE_KCQE_OPCODE_DESTROY_CONN; | ||
| 2413 | kcqe.fcoe_conn_id = req->conn_id; | ||
| 2414 | kcqe.fcoe_conn_context_id = cid; | ||
| 2415 | |||
| 2416 | cqes[0] = (struct kcqe *) &kcqe; | ||
| 2417 | cnic_reply_bnx2x_kcqes(dev, CNIC_ULP_FCOE, cqes, 1); | ||
| 2418 | return ret; | ||
| 2419 | } | ||
| 2420 | |||
| 2421 | static int cnic_bnx2x_fcoe_fw_destroy(struct cnic_dev *dev, struct kwqe *kwqe) | ||
| 2422 | { | ||
| 2423 | struct fcoe_kwqe_destroy *req; | ||
| 2424 | union l5cm_specific_data l5_data; | ||
| 2425 | struct cnic_local *cp = dev->cnic_priv; | ||
| 2426 | int ret; | ||
| 2427 | u32 cid; | ||
| 2428 | |||
| 2429 | req = (struct fcoe_kwqe_destroy *) kwqe; | ||
| 2430 | cid = BNX2X_HW_CID(cp, cp->fcoe_init_cid); | ||
| 2431 | |||
| 2432 | memset(&l5_data, 0, sizeof(l5_data)); | ||
| 2433 | ret = cnic_submit_kwqe_16(dev, FCOE_RAMROD_CMD_ID_DESTROY, cid, | ||
| 2434 | FCOE_CONNECTION_TYPE, &l5_data); | ||
| 2435 | return ret; | ||
| 2436 | } | ||
| 2437 | |||
| 2438 | static int cnic_submit_bnx2x_iscsi_kwqes(struct cnic_dev *dev, | ||
| 2439 | struct kwqe *wqes[], u32 num_wqes) | ||
| 2000 | { | 2440 | { |
| 2001 | int i, work, ret; | 2441 | int i, work, ret; |
| 2002 | u32 opcode; | 2442 | u32 opcode; |
| @@ -2060,10 +2500,102 @@ static int cnic_submit_bnx2x_kwqes(struct cnic_dev *dev, struct kwqe *wqes[], | |||
| 2060 | return 0; | 2500 | return 0; |
| 2061 | } | 2501 | } |
| 2062 | 2502 | ||
| 2503 | static int cnic_submit_bnx2x_fcoe_kwqes(struct cnic_dev *dev, | ||
| 2504 | struct kwqe *wqes[], u32 num_wqes) | ||
| 2505 | { | ||
| 2506 | struct cnic_local *cp = dev->cnic_priv; | ||
| 2507 | int i, work, ret; | ||
| 2508 | u32 opcode; | ||
| 2509 | struct kwqe *kwqe; | ||
| 2510 | |||
| 2511 | if (!test_bit(CNIC_F_CNIC_UP, &dev->flags)) | ||
| 2512 | return -EAGAIN; /* bnx2 is down */ | ||
| 2513 | |||
| 2514 | if (BNX2X_CHIP_NUM(cp->chip_id) == BNX2X_CHIP_NUM_57710) | ||
| 2515 | return -EINVAL; | ||
| 2516 | |||
| 2517 | for (i = 0; i < num_wqes; ) { | ||
| 2518 | kwqe = wqes[i]; | ||
| 2519 | opcode = KWQE_OPCODE(kwqe->kwqe_op_flag); | ||
| 2520 | work = 1; | ||
| 2521 | |||
| 2522 | switch (opcode) { | ||
| 2523 | case FCOE_KWQE_OPCODE_INIT1: | ||
| 2524 | ret = cnic_bnx2x_fcoe_init1(dev, &wqes[i], | ||
| 2525 | num_wqes - i, &work); | ||
| 2526 | break; | ||
| 2527 | case FCOE_KWQE_OPCODE_OFFLOAD_CONN1: | ||
| 2528 | ret = cnic_bnx2x_fcoe_ofld1(dev, &wqes[i], | ||
| 2529 | num_wqes - i, &work); | ||
| 2530 | break; | ||
| 2531 | case FCOE_KWQE_OPCODE_ENABLE_CONN: | ||
| 2532 | ret = cnic_bnx2x_fcoe_enable(dev, kwqe); | ||
| 2533 | break; | ||
| 2534 | case FCOE_KWQE_OPCODE_DISABLE_CONN: | ||
| 2535 | ret = cnic_bnx2x_fcoe_disable(dev, kwqe); | ||
| 2536 | break; | ||
| 2537 | case FCOE_KWQE_OPCODE_DESTROY_CONN: | ||
| 2538 | ret = cnic_bnx2x_fcoe_destroy(dev, kwqe); | ||
| 2539 | break; | ||
| 2540 | case FCOE_KWQE_OPCODE_DESTROY: | ||
| 2541 | ret = cnic_bnx2x_fcoe_fw_destroy(dev, kwqe); | ||
| 2542 | break; | ||
| 2543 | case FCOE_KWQE_OPCODE_STAT: | ||
| 2544 | ret = cnic_bnx2x_fcoe_stat(dev, kwqe); | ||
| 2545 | break; | ||
| 2546 | default: | ||
| 2547 | ret = 0; | ||
| 2548 | netdev_err(dev->netdev, "Unknown type of KWQE(0x%x)\n", | ||
| 2549 | opcode); | ||
| 2550 | break; | ||
| 2551 | } | ||
| 2552 | if (ret < 0) | ||
| 2553 | netdev_err(dev->netdev, "KWQE(0x%x) failed\n", | ||
| 2554 | opcode); | ||
| 2555 | i += work; | ||
| 2556 | } | ||
| 2557 | return 0; | ||
| 2558 | } | ||
| 2559 | |||
| 2560 | static int cnic_submit_bnx2x_kwqes(struct cnic_dev *dev, struct kwqe *wqes[], | ||
| 2561 | u32 num_wqes) | ||
| 2562 | { | ||
| 2563 | int ret = -EINVAL; | ||
| 2564 | u32 layer_code; | ||
| 2565 | |||
| 2566 | if (!test_bit(CNIC_F_CNIC_UP, &dev->flags)) | ||
| 2567 | return -EAGAIN; /* bnx2x is down */ | ||
| 2568 | |||
| 2569 | if (!num_wqes) | ||
| 2570 | return 0; | ||
| 2571 | |||
| 2572 | layer_code = wqes[0]->kwqe_op_flag & KWQE_LAYER_MASK; | ||
| 2573 | switch (layer_code) { | ||
| 2574 | case KWQE_FLAGS_LAYER_MASK_L5_ISCSI: | ||
| 2575 | case KWQE_FLAGS_LAYER_MASK_L4: | ||
| 2576 | case KWQE_FLAGS_LAYER_MASK_L2: | ||
| 2577 | ret = cnic_submit_bnx2x_iscsi_kwqes(dev, wqes, num_wqes); | ||
| 2578 | break; | ||
| 2579 | |||
| 2580 | case KWQE_FLAGS_LAYER_MASK_L5_FCOE: | ||
| 2581 | ret = cnic_submit_bnx2x_fcoe_kwqes(dev, wqes, num_wqes); | ||
| 2582 | break; | ||
| 2583 | } | ||
| 2584 | return ret; | ||
| 2585 | } | ||
| 2586 | |||
| 2587 | static inline u32 cnic_get_kcqe_layer_mask(u32 opflag) | ||
| 2588 | { | ||
| 2589 | if (unlikely(KCQE_OPCODE(opflag) == FCOE_RAMROD_CMD_ID_TERMINATE_CONN)) | ||
| 2590 | return KCQE_FLAGS_LAYER_MASK_L4; | ||
| 2591 | |||
| 2592 | return opflag & KCQE_FLAGS_LAYER_MASK; | ||
| 2593 | } | ||
| 2594 | |||
| 2063 | static void service_kcqes(struct cnic_dev *dev, int num_cqes) | 2595 | static void service_kcqes(struct cnic_dev *dev, int num_cqes) |
| 2064 | { | 2596 | { |
| 2065 | struct cnic_local *cp = dev->cnic_priv; | 2597 | struct cnic_local *cp = dev->cnic_priv; |
| 2066 | int i, j; | 2598 | int i, j, comp = 0; |
| 2067 | 2599 | ||
| 2068 | i = 0; | 2600 | i = 0; |
| 2069 | j = 1; | 2601 | j = 1; |
| @@ -2071,19 +2603,19 @@ static void service_kcqes(struct cnic_dev *dev, int num_cqes) | |||
| 2071 | struct cnic_ulp_ops *ulp_ops; | 2603 | struct cnic_ulp_ops *ulp_ops; |
| 2072 | int ulp_type; | 2604 | int ulp_type; |
| 2073 | u32 kcqe_op_flag = cp->completed_kcq[i]->kcqe_op_flag; | 2605 | u32 kcqe_op_flag = cp->completed_kcq[i]->kcqe_op_flag; |
| 2074 | u32 kcqe_layer = kcqe_op_flag & KCQE_FLAGS_LAYER_MASK; | 2606 | u32 kcqe_layer = cnic_get_kcqe_layer_mask(kcqe_op_flag); |
| 2075 | 2607 | ||
| 2076 | if (unlikely(kcqe_op_flag & KCQE_RAMROD_COMPLETION)) | 2608 | if (unlikely(kcqe_op_flag & KCQE_RAMROD_COMPLETION)) |
| 2077 | cnic_kwq_completion(dev, 1); | 2609 | comp++; |
| 2078 | 2610 | ||
| 2079 | while (j < num_cqes) { | 2611 | while (j < num_cqes) { |
| 2080 | u32 next_op = cp->completed_kcq[i + j]->kcqe_op_flag; | 2612 | u32 next_op = cp->completed_kcq[i + j]->kcqe_op_flag; |
| 2081 | 2613 | ||
| 2082 | if ((next_op & KCQE_FLAGS_LAYER_MASK) != kcqe_layer) | 2614 | if (cnic_get_kcqe_layer_mask(next_op) != kcqe_layer) |
| 2083 | break; | 2615 | break; |
| 2084 | 2616 | ||
| 2085 | if (unlikely(next_op & KCQE_RAMROD_COMPLETION)) | 2617 | if (unlikely(next_op & KCQE_RAMROD_COMPLETION)) |
| 2086 | cnic_kwq_completion(dev, 1); | 2618 | comp++; |
| 2087 | j++; | 2619 | j++; |
| 2088 | } | 2620 | } |
| 2089 | 2621 | ||
| @@ -2091,6 +2623,8 @@ static void service_kcqes(struct cnic_dev *dev, int num_cqes) | |||
| 2091 | ulp_type = CNIC_ULP_RDMA; | 2623 | ulp_type = CNIC_ULP_RDMA; |
| 2092 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L5_ISCSI) | 2624 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L5_ISCSI) |
| 2093 | ulp_type = CNIC_ULP_ISCSI; | 2625 | ulp_type = CNIC_ULP_ISCSI; |
| 2626 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L5_FCOE) | ||
| 2627 | ulp_type = CNIC_ULP_FCOE; | ||
| 2094 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L4) | 2628 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L4) |
| 2095 | ulp_type = CNIC_ULP_L4; | 2629 | ulp_type = CNIC_ULP_L4; |
| 2096 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L2) | 2630 | else if (kcqe_layer == KCQE_FLAGS_LAYER_MASK_L2) |
| @@ -2113,6 +2647,8 @@ end: | |||
| 2113 | i += j; | 2647 | i += j; |
| 2114 | j = 1; | 2648 | j = 1; |
| 2115 | } | 2649 | } |
| 2650 | if (unlikely(comp)) | ||
| 2651 | cnic_spq_completion(dev, DRV_CTL_RET_L5_SPQ_CREDIT_CMD, comp); | ||
| 2116 | } | 2652 | } |
| 2117 | 2653 | ||
| 2118 | static u16 cnic_bnx2_next_idx(u16 idx) | 2654 | static u16 cnic_bnx2_next_idx(u16 idx) |
| @@ -2171,8 +2707,9 @@ static int cnic_get_kcqes(struct cnic_dev *dev, struct kcq_info *info) | |||
| 2171 | static int cnic_l2_completion(struct cnic_local *cp) | 2707 | static int cnic_l2_completion(struct cnic_local *cp) |
| 2172 | { | 2708 | { |
| 2173 | u16 hw_cons, sw_cons; | 2709 | u16 hw_cons, sw_cons; |
| 2710 | struct cnic_uio_dev *udev = cp->udev; | ||
| 2174 | union eth_rx_cqe *cqe, *cqe_ring = (union eth_rx_cqe *) | 2711 | union eth_rx_cqe *cqe, *cqe_ring = (union eth_rx_cqe *) |
| 2175 | (cp->l2_ring + (2 * BCM_PAGE_SIZE)); | 2712 | (udev->l2_ring + (2 * BCM_PAGE_SIZE)); |
| 2176 | u32 cmd; | 2713 | u32 cmd; |
| 2177 | int comp = 0; | 2714 | int comp = 0; |
| 2178 | 2715 | ||
| @@ -2203,13 +2740,14 @@ static int cnic_l2_completion(struct cnic_local *cp) | |||
| 2203 | 2740 | ||
| 2204 | static void cnic_chk_pkt_rings(struct cnic_local *cp) | 2741 | static void cnic_chk_pkt_rings(struct cnic_local *cp) |
| 2205 | { | 2742 | { |
| 2206 | u16 rx_cons = *cp->rx_cons_ptr; | 2743 | u16 rx_cons, tx_cons; |
| 2207 | u16 tx_cons = *cp->tx_cons_ptr; | ||
| 2208 | int comp = 0; | 2744 | int comp = 0; |
| 2209 | 2745 | ||
| 2210 | if (!test_bit(CNIC_F_CNIC_UP, &cp->dev->flags)) | 2746 | if (!test_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags)) |
| 2211 | return; | 2747 | return; |
| 2212 | 2748 | ||
| 2749 | rx_cons = *cp->rx_cons_ptr; | ||
| 2750 | tx_cons = *cp->tx_cons_ptr; | ||
| 2213 | if (cp->tx_cons != tx_cons || cp->rx_cons != rx_cons) { | 2751 | if (cp->tx_cons != tx_cons || cp->rx_cons != rx_cons) { |
| 2214 | if (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags)) | 2752 | if (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags)) |
| 2215 | comp = cnic_l2_completion(cp); | 2753 | comp = cnic_l2_completion(cp); |
| @@ -2217,7 +2755,8 @@ static void cnic_chk_pkt_rings(struct cnic_local *cp) | |||
| 2217 | cp->tx_cons = tx_cons; | 2755 | cp->tx_cons = tx_cons; |
| 2218 | cp->rx_cons = rx_cons; | 2756 | cp->rx_cons = rx_cons; |
| 2219 | 2757 | ||
| 2220 | uio_event_notify(cp->cnic_uinfo); | 2758 | if (cp->udev) |
| 2759 | uio_event_notify(&cp->udev->cnic_uinfo); | ||
| 2221 | } | 2760 | } |
| 2222 | if (comp) | 2761 | if (comp) |
| 2223 | clear_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); | 2762 | clear_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); |
| @@ -2229,6 +2768,8 @@ static u32 cnic_service_bnx2_queues(struct cnic_dev *dev) | |||
| 2229 | u32 status_idx = (u16) *cp->kcq1.status_idx_ptr; | 2768 | u32 status_idx = (u16) *cp->kcq1.status_idx_ptr; |
| 2230 | int kcqe_cnt; | 2769 | int kcqe_cnt; |
| 2231 | 2770 | ||
| 2771 | /* status block index must be read before reading other fields */ | ||
| 2772 | rmb(); | ||
| 2232 | cp->kwq_con_idx = *cp->kwq_con_idx_ptr; | 2773 | cp->kwq_con_idx = *cp->kwq_con_idx_ptr; |
| 2233 | 2774 | ||
| 2234 | while ((kcqe_cnt = cnic_get_kcqes(dev, &cp->kcq1))) { | 2775 | while ((kcqe_cnt = cnic_get_kcqes(dev, &cp->kcq1))) { |
| @@ -2239,6 +2780,8 @@ static u32 cnic_service_bnx2_queues(struct cnic_dev *dev) | |||
| 2239 | barrier(); | 2780 | barrier(); |
| 2240 | if (status_idx != *cp->kcq1.status_idx_ptr) { | 2781 | if (status_idx != *cp->kcq1.status_idx_ptr) { |
| 2241 | status_idx = (u16) *cp->kcq1.status_idx_ptr; | 2782 | status_idx = (u16) *cp->kcq1.status_idx_ptr; |
| 2783 | /* status block index must be read first */ | ||
| 2784 | rmb(); | ||
| 2242 | cp->kwq_con_idx = *cp->kwq_con_idx_ptr; | 2785 | cp->kwq_con_idx = *cp->kwq_con_idx_ptr; |
| 2243 | } else | 2786 | } else |
| 2244 | break; | 2787 | break; |
| @@ -2254,11 +2797,12 @@ static u32 cnic_service_bnx2_queues(struct cnic_dev *dev) | |||
| 2254 | static int cnic_service_bnx2(void *data, void *status_blk) | 2797 | static int cnic_service_bnx2(void *data, void *status_blk) |
| 2255 | { | 2798 | { |
| 2256 | struct cnic_dev *dev = data; | 2799 | struct cnic_dev *dev = data; |
| 2257 | struct cnic_local *cp = dev->cnic_priv; | ||
| 2258 | u32 status_idx = *cp->kcq1.status_idx_ptr; | ||
| 2259 | 2800 | ||
| 2260 | if (unlikely(!test_bit(CNIC_F_CNIC_UP, &dev->flags))) | 2801 | if (unlikely(!test_bit(CNIC_F_CNIC_UP, &dev->flags))) { |
| 2261 | return status_idx; | 2802 | struct status_block *sblk = status_blk; |
| 2803 | |||
| 2804 | return sblk->status_idx; | ||
| 2805 | } | ||
| 2262 | 2806 | ||
| 2263 | return cnic_service_bnx2_queues(dev); | 2807 | return cnic_service_bnx2_queues(dev); |
| 2264 | } | 2808 | } |
| @@ -2277,9 +2821,10 @@ static void cnic_service_bnx2_msix(unsigned long data) | |||
| 2277 | static void cnic_doirq(struct cnic_dev *dev) | 2821 | static void cnic_doirq(struct cnic_dev *dev) |
| 2278 | { | 2822 | { |
| 2279 | struct cnic_local *cp = dev->cnic_priv; | 2823 | struct cnic_local *cp = dev->cnic_priv; |
| 2280 | u16 prod = cp->kcq1.sw_prod_idx & MAX_KCQ_IDX; | ||
| 2281 | 2824 | ||
| 2282 | if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags))) { | 2825 | if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags))) { |
| 2826 | u16 prod = cp->kcq1.sw_prod_idx & MAX_KCQ_IDX; | ||
| 2827 | |||
| 2283 | prefetch(cp->status_blk.gen); | 2828 | prefetch(cp->status_blk.gen); |
| 2284 | prefetch(&cp->kcq1.kcq[KCQ_PG(prod)][KCQ_IDX(prod)]); | 2829 | prefetch(&cp->kcq1.kcq[KCQ_PG(prod)][KCQ_IDX(prod)]); |
| 2285 | 2830 | ||
| @@ -2318,19 +2863,45 @@ static inline void cnic_ack_bnx2x_int(struct cnic_dev *dev, u8 id, u8 storm, | |||
| 2318 | CNIC_WR(dev, hc_addr, (*(u32 *)&igu_ack)); | 2863 | CNIC_WR(dev, hc_addr, (*(u32 *)&igu_ack)); |
| 2319 | } | 2864 | } |
| 2320 | 2865 | ||
| 2866 | static void cnic_ack_igu_sb(struct cnic_dev *dev, u8 igu_sb_id, u8 segment, | ||
| 2867 | u16 index, u8 op, u8 update) | ||
| 2868 | { | ||
| 2869 | struct igu_regular cmd_data; | ||
| 2870 | u32 igu_addr = BAR_IGU_INTMEM + (IGU_CMD_INT_ACK_BASE + igu_sb_id) * 8; | ||
| 2871 | |||
| 2872 | cmd_data.sb_id_and_flags = | ||
| 2873 | (index << IGU_REGULAR_SB_INDEX_SHIFT) | | ||
| 2874 | (segment << IGU_REGULAR_SEGMENT_ACCESS_SHIFT) | | ||
| 2875 | (update << IGU_REGULAR_BUPDATE_SHIFT) | | ||
| 2876 | (op << IGU_REGULAR_ENABLE_INT_SHIFT); | ||
| 2877 | |||
| 2878 | |||
| 2879 | CNIC_WR(dev, igu_addr, cmd_data.sb_id_and_flags); | ||
| 2880 | } | ||
| 2881 | |||
| 2321 | static void cnic_ack_bnx2x_msix(struct cnic_dev *dev) | 2882 | static void cnic_ack_bnx2x_msix(struct cnic_dev *dev) |
| 2322 | { | 2883 | { |
| 2323 | struct cnic_local *cp = dev->cnic_priv; | 2884 | struct cnic_local *cp = dev->cnic_priv; |
| 2324 | 2885 | ||
| 2325 | cnic_ack_bnx2x_int(dev, cp->status_blk_num, CSTORM_ID, 0, | 2886 | cnic_ack_bnx2x_int(dev, cp->bnx2x_igu_sb_id, CSTORM_ID, 0, |
| 2326 | IGU_INT_DISABLE, 0); | 2887 | IGU_INT_DISABLE, 0); |
| 2327 | } | 2888 | } |
| 2328 | 2889 | ||
| 2890 | static void cnic_ack_bnx2x_e2_msix(struct cnic_dev *dev) | ||
| 2891 | { | ||
| 2892 | struct cnic_local *cp = dev->cnic_priv; | ||
| 2893 | |||
| 2894 | cnic_ack_igu_sb(dev, cp->bnx2x_igu_sb_id, IGU_SEG_ACCESS_DEF, 0, | ||
| 2895 | IGU_INT_DISABLE, 0); | ||
| 2896 | } | ||
| 2897 | |||
| 2329 | static u32 cnic_service_bnx2x_kcq(struct cnic_dev *dev, struct kcq_info *info) | 2898 | static u32 cnic_service_bnx2x_kcq(struct cnic_dev *dev, struct kcq_info *info) |
| 2330 | { | 2899 | { |
| 2331 | u32 last_status = *info->status_idx_ptr; | 2900 | u32 last_status = *info->status_idx_ptr; |
| 2332 | int kcqe_cnt; | 2901 | int kcqe_cnt; |
| 2333 | 2902 | ||
| 2903 | /* status block index must be read before reading the KCQ */ | ||
| 2904 | rmb(); | ||
| 2334 | while ((kcqe_cnt = cnic_get_kcqes(dev, info))) { | 2905 | while ((kcqe_cnt = cnic_get_kcqes(dev, info))) { |
| 2335 | 2906 | ||
| 2336 | service_kcqes(dev, kcqe_cnt); | 2907 | service_kcqes(dev, kcqe_cnt); |
| @@ -2341,6 +2912,8 @@ static u32 cnic_service_bnx2x_kcq(struct cnic_dev *dev, struct kcq_info *info) | |||
| 2341 | break; | 2912 | break; |
| 2342 | 2913 | ||
| 2343 | last_status = *info->status_idx_ptr; | 2914 | last_status = *info->status_idx_ptr; |
| 2915 | /* status block index must be read before reading the KCQ */ | ||
| 2916 | rmb(); | ||
| 2344 | } | 2917 | } |
| 2345 | return last_status; | 2918 | return last_status; |
| 2346 | } | 2919 | } |
| @@ -2349,16 +2922,36 @@ static void cnic_service_bnx2x_bh(unsigned long data) | |||
| 2349 | { | 2922 | { |
| 2350 | struct cnic_dev *dev = (struct cnic_dev *) data; | 2923 | struct cnic_dev *dev = (struct cnic_dev *) data; |
| 2351 | struct cnic_local *cp = dev->cnic_priv; | 2924 | struct cnic_local *cp = dev->cnic_priv; |
| 2352 | u32 status_idx; | 2925 | u32 status_idx, new_status_idx; |
| 2353 | 2926 | ||
| 2354 | if (unlikely(!test_bit(CNIC_F_CNIC_UP, &dev->flags))) | 2927 | if (unlikely(!test_bit(CNIC_F_CNIC_UP, &dev->flags))) |
| 2355 | return; | 2928 | return; |
| 2356 | 2929 | ||
| 2357 | status_idx = cnic_service_bnx2x_kcq(dev, &cp->kcq1); | 2930 | while (1) { |
| 2931 | status_idx = cnic_service_bnx2x_kcq(dev, &cp->kcq1); | ||
| 2932 | |||
| 2933 | CNIC_WR16(dev, cp->kcq1.io_addr, | ||
| 2934 | cp->kcq1.sw_prod_idx + MAX_KCQ_IDX); | ||
| 2935 | |||
| 2936 | if (!BNX2X_CHIP_IS_E2(cp->chip_id)) { | ||
| 2937 | cnic_ack_bnx2x_int(dev, cp->bnx2x_igu_sb_id, USTORM_ID, | ||
| 2938 | status_idx, IGU_INT_ENABLE, 1); | ||
| 2939 | break; | ||
| 2940 | } | ||
| 2941 | |||
| 2942 | new_status_idx = cnic_service_bnx2x_kcq(dev, &cp->kcq2); | ||
| 2358 | 2943 | ||
| 2359 | CNIC_WR16(dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx + MAX_KCQ_IDX); | 2944 | if (new_status_idx != status_idx) |
| 2360 | cnic_ack_bnx2x_int(dev, cp->status_blk_num, CSTORM_ID, | 2945 | continue; |
| 2361 | status_idx, IGU_INT_ENABLE, 1); | 2946 | |
| 2947 | CNIC_WR16(dev, cp->kcq2.io_addr, cp->kcq2.sw_prod_idx + | ||
| 2948 | MAX_KCQ_IDX); | ||
| 2949 | |||
| 2950 | cnic_ack_igu_sb(dev, cp->bnx2x_igu_sb_id, IGU_SEG_ACCESS_DEF, | ||
| 2951 | status_idx, IGU_INT_ENABLE, 1); | ||
| 2952 | |||
| 2953 | break; | ||
| 2954 | } | ||
| 2362 | } | 2955 | } |
| 2363 | 2956 | ||
| 2364 | static int cnic_service_bnx2x(void *data, void *status_blk) | 2957 | static int cnic_service_bnx2x(void *data, void *status_blk) |
| @@ -2374,31 +2967,36 @@ static int cnic_service_bnx2x(void *data, void *status_blk) | |||
| 2374 | return 0; | 2967 | return 0; |
| 2375 | } | 2968 | } |
| 2376 | 2969 | ||
| 2377 | static void cnic_ulp_stop(struct cnic_dev *dev) | 2970 | static void cnic_ulp_stop_one(struct cnic_local *cp, int if_type) |
| 2378 | { | 2971 | { |
| 2379 | struct cnic_local *cp = dev->cnic_priv; | 2972 | struct cnic_ulp_ops *ulp_ops; |
| 2380 | int if_type; | ||
| 2381 | 2973 | ||
| 2382 | if (cp->cnic_uinfo) | 2974 | if (if_type == CNIC_ULP_ISCSI) |
| 2383 | cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); | 2975 | cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); |
| 2384 | 2976 | ||
| 2385 | for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) { | 2977 | mutex_lock(&cnic_lock); |
| 2386 | struct cnic_ulp_ops *ulp_ops; | 2978 | ulp_ops = rcu_dereference_protected(cp->ulp_ops[if_type], |
| 2387 | 2979 | lockdep_is_held(&cnic_lock)); | |
| 2388 | mutex_lock(&cnic_lock); | 2980 | if (!ulp_ops) { |
| 2389 | ulp_ops = cp->ulp_ops[if_type]; | ||
| 2390 | if (!ulp_ops) { | ||
| 2391 | mutex_unlock(&cnic_lock); | ||
| 2392 | continue; | ||
| 2393 | } | ||
| 2394 | set_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]); | ||
| 2395 | mutex_unlock(&cnic_lock); | 2981 | mutex_unlock(&cnic_lock); |
| 2982 | return; | ||
| 2983 | } | ||
| 2984 | set_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]); | ||
| 2985 | mutex_unlock(&cnic_lock); | ||
| 2396 | 2986 | ||
| 2397 | if (test_and_clear_bit(ULP_F_START, &cp->ulp_flags[if_type])) | 2987 | if (test_and_clear_bit(ULP_F_START, &cp->ulp_flags[if_type])) |
| 2398 | ulp_ops->cnic_stop(cp->ulp_handle[if_type]); | 2988 | ulp_ops->cnic_stop(cp->ulp_handle[if_type]); |
| 2399 | 2989 | ||
| 2400 | clear_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]); | 2990 | clear_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]); |
| 2401 | } | 2991 | } |
| 2992 | |||
| 2993 | static void cnic_ulp_stop(struct cnic_dev *dev) | ||
| 2994 | { | ||
| 2995 | struct cnic_local *cp = dev->cnic_priv; | ||
| 2996 | int if_type; | ||
| 2997 | |||
| 2998 | for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) | ||
| 2999 | cnic_ulp_stop_one(cp, if_type); | ||
| 2402 | } | 3000 | } |
| 2403 | 3001 | ||
| 2404 | static void cnic_ulp_start(struct cnic_dev *dev) | 3002 | static void cnic_ulp_start(struct cnic_dev *dev) |
| @@ -2410,7 +3008,8 @@ static void cnic_ulp_start(struct cnic_dev *dev) | |||
| 2410 | struct cnic_ulp_ops *ulp_ops; | 3008 | struct cnic_ulp_ops *ulp_ops; |
| 2411 | 3009 | ||
| 2412 | mutex_lock(&cnic_lock); | 3010 | mutex_lock(&cnic_lock); |
| 2413 | ulp_ops = cp->ulp_ops[if_type]; | 3011 | ulp_ops = rcu_dereference_protected(cp->ulp_ops[if_type], |
| 3012 | lockdep_is_held(&cnic_lock)); | ||
| 2414 | if (!ulp_ops || !ulp_ops->cnic_start) { | 3013 | if (!ulp_ops || !ulp_ops->cnic_start) { |
| 2415 | mutex_unlock(&cnic_lock); | 3014 | mutex_unlock(&cnic_lock); |
| 2416 | continue; | 3015 | continue; |
| @@ -2446,6 +3045,12 @@ static int cnic_ctl(void *data, struct cnic_ctl_info *info) | |||
| 2446 | 3045 | ||
| 2447 | cnic_put(dev); | 3046 | cnic_put(dev); |
| 2448 | break; | 3047 | break; |
| 3048 | case CNIC_CTL_STOP_ISCSI_CMD: { | ||
| 3049 | struct cnic_local *cp = dev->cnic_priv; | ||
| 3050 | set_bit(CNIC_LCL_FL_STOP_ISCSI, &cp->cnic_local_flags); | ||
| 3051 | queue_delayed_work(cnic_wq, &cp->delete_task, 0); | ||
| 3052 | break; | ||
| 3053 | } | ||
| 2449 | case CNIC_CTL_COMPLETION_CMD: { | 3054 | case CNIC_CTL_COMPLETION_CMD: { |
| 2450 | u32 cid = BNX2X_SW_CID(info->data.comp.cid); | 3055 | u32 cid = BNX2X_SW_CID(info->data.comp.cid); |
| 2451 | u32 l5_cid; | 3056 | u32 l5_cid; |
| @@ -2474,7 +3079,7 @@ static void cnic_ulp_init(struct cnic_dev *dev) | |||
| 2474 | struct cnic_ulp_ops *ulp_ops; | 3079 | struct cnic_ulp_ops *ulp_ops; |
| 2475 | 3080 | ||
| 2476 | mutex_lock(&cnic_lock); | 3081 | mutex_lock(&cnic_lock); |
| 2477 | ulp_ops = cnic_ulp_tbl[i]; | 3082 | ulp_ops = cnic_ulp_tbl_prot(i); |
| 2478 | if (!ulp_ops || !ulp_ops->cnic_init) { | 3083 | if (!ulp_ops || !ulp_ops->cnic_init) { |
| 2479 | mutex_unlock(&cnic_lock); | 3084 | mutex_unlock(&cnic_lock); |
| 2480 | continue; | 3085 | continue; |
| @@ -2498,7 +3103,7 @@ static void cnic_ulp_exit(struct cnic_dev *dev) | |||
| 2498 | struct cnic_ulp_ops *ulp_ops; | 3103 | struct cnic_ulp_ops *ulp_ops; |
| 2499 | 3104 | ||
| 2500 | mutex_lock(&cnic_lock); | 3105 | mutex_lock(&cnic_lock); |
| 2501 | ulp_ops = cnic_ulp_tbl[i]; | 3106 | ulp_ops = cnic_ulp_tbl_prot(i); |
| 2502 | if (!ulp_ops || !ulp_ops->cnic_exit) { | 3107 | if (!ulp_ops || !ulp_ops->cnic_exit) { |
| 2503 | mutex_unlock(&cnic_lock); | 3108 | mutex_unlock(&cnic_lock); |
| 2504 | continue; | 3109 | continue; |
| @@ -2728,6 +3333,13 @@ static int cnic_cm_create(struct cnic_dev *dev, int ulp_type, u32 cid, | |||
| 2728 | if (l5_cid >= MAX_CM_SK_TBL_SZ) | 3333 | if (l5_cid >= MAX_CM_SK_TBL_SZ) |
| 2729 | return -EINVAL; | 3334 | return -EINVAL; |
| 2730 | 3335 | ||
| 3336 | if (cp->ctx_tbl) { | ||
| 3337 | struct cnic_context *ctx = &cp->ctx_tbl[l5_cid]; | ||
| 3338 | |||
| 3339 | if (test_bit(CTX_FL_OFFLD_START, &ctx->ctx_flags)) | ||
| 3340 | return -EAGAIN; | ||
| 3341 | } | ||
| 3342 | |||
| 2731 | csk1 = &cp->csk_tbl[l5_cid]; | 3343 | csk1 = &cp->csk_tbl[l5_cid]; |
| 2732 | if (atomic_read(&csk1->ref_count)) | 3344 | if (atomic_read(&csk1->ref_count)) |
| 2733 | return -EAGAIN; | 3345 | return -EAGAIN; |
| @@ -2761,7 +3373,7 @@ static void cnic_cm_cleanup(struct cnic_sock *csk) | |||
| 2761 | struct cnic_dev *dev = csk->dev; | 3373 | struct cnic_dev *dev = csk->dev; |
| 2762 | struct cnic_local *cp = dev->cnic_priv; | 3374 | struct cnic_local *cp = dev->cnic_priv; |
| 2763 | 3375 | ||
| 2764 | cnic_free_id(&cp->csk_port_tbl, csk->src_port); | 3376 | cnic_free_id(&cp->csk_port_tbl, be16_to_cpu(csk->src_port)); |
| 2765 | csk->src_port = 0; | 3377 | csk->src_port = 0; |
| 2766 | } | 3378 | } |
| 2767 | } | 3379 | } |
| @@ -2807,17 +3419,14 @@ static int cnic_get_v4_route(struct sockaddr_in *dst_addr, | |||
| 2807 | struct dst_entry **dst) | 3419 | struct dst_entry **dst) |
| 2808 | { | 3420 | { |
| 2809 | #if defined(CONFIG_INET) | 3421 | #if defined(CONFIG_INET) |
| 2810 | struct flowi fl; | ||
| 2811 | int err; | ||
| 2812 | struct rtable *rt; | 3422 | struct rtable *rt; |
| 2813 | 3423 | ||
| 2814 | memset(&fl, 0, sizeof(fl)); | 3424 | rt = ip_route_output(&init_net, dst_addr->sin_addr.s_addr, 0, 0, 0); |
| 2815 | fl.nl_u.ip4_u.daddr = dst_addr->sin_addr.s_addr; | 3425 | if (!IS_ERR(rt)) { |
| 2816 | |||
| 2817 | err = ip_route_output_key(&init_net, &rt, &fl); | ||
| 2818 | if (!err) | ||
| 2819 | *dst = &rt->dst; | 3426 | *dst = &rt->dst; |
| 2820 | return err; | 3427 | return 0; |
| 3428 | } | ||
| 3429 | return PTR_ERR(rt); | ||
| 2821 | #else | 3430 | #else |
| 2822 | return -ENETUNREACH; | 3431 | return -ENETUNREACH; |
| 2823 | #endif | 3432 | #endif |
| @@ -2827,14 +3436,14 @@ static int cnic_get_v6_route(struct sockaddr_in6 *dst_addr, | |||
| 2827 | struct dst_entry **dst) | 3436 | struct dst_entry **dst) |
| 2828 | { | 3437 | { |
| 2829 | #if defined(CONFIG_IPV6) || (defined(CONFIG_IPV6_MODULE) && defined(MODULE)) | 3438 | #if defined(CONFIG_IPV6) || (defined(CONFIG_IPV6_MODULE) && defined(MODULE)) |
| 2830 | struct flowi fl; | 3439 | struct flowi6 fl6; |
| 2831 | 3440 | ||
| 2832 | memset(&fl, 0, sizeof(fl)); | 3441 | memset(&fl6, 0, sizeof(fl6)); |
| 2833 | ipv6_addr_copy(&fl.fl6_dst, &dst_addr->sin6_addr); | 3442 | ipv6_addr_copy(&fl6.daddr, &dst_addr->sin6_addr); |
| 2834 | if (ipv6_addr_type(&fl.fl6_dst) & IPV6_ADDR_LINKLOCAL) | 3443 | if (ipv6_addr_type(&fl6.daddr) & IPV6_ADDR_LINKLOCAL) |
| 2835 | fl.oif = dst_addr->sin6_scope_id; | 3444 | fl6.flowi6_oif = dst_addr->sin6_scope_id; |
| 2836 | 3445 | ||
| 2837 | *dst = ip6_route_output(&init_net, NULL, &fl); | 3446 | *dst = ip6_route_output(&init_net, NULL, &fl6); |
| 2838 | if (*dst) | 3447 | if (*dst) |
| 2839 | return 0; | 3448 | return 0; |
| 2840 | #endif | 3449 | #endif |
| @@ -2892,7 +3501,8 @@ static int cnic_get_route(struct cnic_sock *csk, struct cnic_sockaddr *saddr) | |||
| 2892 | int is_v6, rc = 0; | 3501 | int is_v6, rc = 0; |
| 2893 | struct dst_entry *dst = NULL; | 3502 | struct dst_entry *dst = NULL; |
| 2894 | struct net_device *realdev; | 3503 | struct net_device *realdev; |
| 2895 | u32 local_port; | 3504 | __be16 local_port; |
| 3505 | u32 port_id; | ||
| 2896 | 3506 | ||
| 2897 | if (saddr->local.v6.sin6_family == AF_INET6 && | 3507 | if (saddr->local.v6.sin6_family == AF_INET6 && |
| 2898 | saddr->remote.v6.sin6_family == AF_INET6) | 3508 | saddr->remote.v6.sin6_family == AF_INET6) |
| @@ -2932,19 +3542,21 @@ static int cnic_get_route(struct cnic_sock *csk, struct cnic_sockaddr *saddr) | |||
| 2932 | } | 3542 | } |
| 2933 | } | 3543 | } |
| 2934 | 3544 | ||
| 2935 | if (local_port >= CNIC_LOCAL_PORT_MIN && | 3545 | port_id = be16_to_cpu(local_port); |
| 2936 | local_port < CNIC_LOCAL_PORT_MAX) { | 3546 | if (port_id >= CNIC_LOCAL_PORT_MIN && |
| 2937 | if (cnic_alloc_id(&cp->csk_port_tbl, local_port)) | 3547 | port_id < CNIC_LOCAL_PORT_MAX) { |
| 2938 | local_port = 0; | 3548 | if (cnic_alloc_id(&cp->csk_port_tbl, port_id)) |
| 3549 | port_id = 0; | ||
| 2939 | } else | 3550 | } else |
| 2940 | local_port = 0; | 3551 | port_id = 0; |
| 2941 | 3552 | ||
| 2942 | if (!local_port) { | 3553 | if (!port_id) { |
| 2943 | local_port = cnic_alloc_new_id(&cp->csk_port_tbl); | 3554 | port_id = cnic_alloc_new_id(&cp->csk_port_tbl); |
| 2944 | if (local_port == -1) { | 3555 | if (port_id == -1) { |
| 2945 | rc = -ENOMEM; | 3556 | rc = -ENOMEM; |
| 2946 | goto err_out; | 3557 | goto err_out; |
| 2947 | } | 3558 | } |
| 3559 | local_port = cpu_to_be16(port_id); | ||
| 2948 | } | 3560 | } |
| 2949 | csk->src_port = local_port; | 3561 | csk->src_port = local_port; |
| 2950 | 3562 | ||
| @@ -2962,8 +3574,12 @@ static void cnic_init_csk_state(struct cnic_sock *csk) | |||
| 2962 | 3574 | ||
| 2963 | static int cnic_cm_connect(struct cnic_sock *csk, struct cnic_sockaddr *saddr) | 3575 | static int cnic_cm_connect(struct cnic_sock *csk, struct cnic_sockaddr *saddr) |
| 2964 | { | 3576 | { |
| 3577 | struct cnic_local *cp = csk->dev->cnic_priv; | ||
| 2965 | int err = 0; | 3578 | int err = 0; |
| 2966 | 3579 | ||
| 3580 | if (cp->ethdev->drv_state & CNIC_DRV_STATE_NO_ISCSI) | ||
| 3581 | return -EOPNOTSUPP; | ||
| 3582 | |||
| 2967 | if (!cnic_in_use(csk)) | 3583 | if (!cnic_in_use(csk)) |
| 2968 | return -EINVAL; | 3584 | return -EINVAL; |
| 2969 | 3585 | ||
| @@ -3086,6 +3702,18 @@ done: | |||
| 3086 | csk_put(csk); | 3702 | csk_put(csk); |
| 3087 | } | 3703 | } |
| 3088 | 3704 | ||
| 3705 | static void cnic_process_fcoe_term_conn(struct cnic_dev *dev, struct kcqe *kcqe) | ||
| 3706 | { | ||
| 3707 | struct cnic_local *cp = dev->cnic_priv; | ||
| 3708 | struct fcoe_kcqe *fc_kcqe = (struct fcoe_kcqe *) kcqe; | ||
| 3709 | u32 l5_cid = fc_kcqe->fcoe_conn_id + BNX2X_FCOE_L5_CID_BASE; | ||
| 3710 | struct cnic_context *ctx = &cp->ctx_tbl[l5_cid]; | ||
| 3711 | |||
| 3712 | ctx->timestamp = jiffies; | ||
| 3713 | ctx->wait_cond = 1; | ||
| 3714 | wake_up(&ctx->waitq); | ||
| 3715 | } | ||
| 3716 | |||
| 3089 | static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe) | 3717 | static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe) |
| 3090 | { | 3718 | { |
| 3091 | struct cnic_local *cp = dev->cnic_priv; | 3719 | struct cnic_local *cp = dev->cnic_priv; |
| @@ -3094,6 +3722,10 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe) | |||
| 3094 | u32 l5_cid; | 3722 | u32 l5_cid; |
| 3095 | struct cnic_sock *csk; | 3723 | struct cnic_sock *csk; |
| 3096 | 3724 | ||
| 3725 | if (opcode == FCOE_RAMROD_CMD_ID_TERMINATE_CONN) { | ||
| 3726 | cnic_process_fcoe_term_conn(dev, kcqe); | ||
| 3727 | return; | ||
| 3728 | } | ||
| 3097 | if (opcode == L4_KCQE_OPCODE_VALUE_OFFLOAD_PG || | 3729 | if (opcode == L4_KCQE_OPCODE_VALUE_OFFLOAD_PG || |
| 3098 | opcode == L4_KCQE_OPCODE_VALUE_UPDATE_PG) { | 3730 | opcode == L4_KCQE_OPCODE_VALUE_UPDATE_PG) { |
| 3099 | cnic_cm_process_offld_pg(dev, l4kcqe); | 3731 | cnic_cm_process_offld_pg(dev, l4kcqe); |
| @@ -3279,39 +3911,115 @@ static void cnic_close_bnx2x_conn(struct cnic_sock *csk, u32 opcode) | |||
| 3279 | 3911 | ||
| 3280 | static void cnic_cm_stop_bnx2x_hw(struct cnic_dev *dev) | 3912 | static void cnic_cm_stop_bnx2x_hw(struct cnic_dev *dev) |
| 3281 | { | 3913 | { |
| 3914 | struct cnic_local *cp = dev->cnic_priv; | ||
| 3915 | int i; | ||
| 3916 | |||
| 3917 | if (!cp->ctx_tbl) | ||
| 3918 | return; | ||
| 3919 | |||
| 3920 | if (!netif_running(dev->netdev)) | ||
| 3921 | return; | ||
| 3922 | |||
| 3923 | for (i = 0; i < cp->max_cid_space; i++) { | ||
| 3924 | struct cnic_context *ctx = &cp->ctx_tbl[i]; | ||
| 3925 | |||
| 3926 | while (test_bit(CTX_FL_DELETE_WAIT, &ctx->ctx_flags)) | ||
| 3927 | msleep(10); | ||
| 3928 | |||
| 3929 | if (test_bit(CTX_FL_OFFLD_START, &ctx->ctx_flags)) | ||
| 3930 | netdev_warn(dev->netdev, "CID %x not deleted\n", | ||
| 3931 | ctx->cid); | ||
| 3932 | } | ||
| 3933 | |||
| 3934 | cancel_delayed_work(&cp->delete_task); | ||
| 3935 | flush_workqueue(cnic_wq); | ||
| 3936 | |||
| 3937 | if (atomic_read(&cp->iscsi_conn) != 0) | ||
| 3938 | netdev_warn(dev->netdev, "%d iSCSI connections not destroyed\n", | ||
| 3939 | atomic_read(&cp->iscsi_conn)); | ||
| 3282 | } | 3940 | } |
| 3283 | 3941 | ||
| 3284 | static int cnic_cm_init_bnx2x_hw(struct cnic_dev *dev) | 3942 | static int cnic_cm_init_bnx2x_hw(struct cnic_dev *dev) |
| 3285 | { | 3943 | { |
| 3286 | struct cnic_local *cp = dev->cnic_priv; | 3944 | struct cnic_local *cp = dev->cnic_priv; |
| 3287 | int func = CNIC_FUNC(cp); | 3945 | u32 pfid = cp->pfid; |
| 3946 | u32 port = CNIC_PORT(cp); | ||
| 3288 | 3947 | ||
| 3289 | cnic_init_bnx2x_mac(dev); | 3948 | cnic_init_bnx2x_mac(dev); |
| 3290 | cnic_bnx2x_set_tcp_timestamp(dev, 1); | 3949 | cnic_bnx2x_set_tcp_timestamp(dev, 1); |
| 3291 | 3950 | ||
| 3292 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + | 3951 | CNIC_WR16(dev, BAR_XSTRORM_INTMEM + |
| 3293 | XSTORM_ISCSI_LOCAL_VLAN_OFFSET(func), 0); | 3952 | XSTORM_ISCSI_LOCAL_VLAN_OFFSET(pfid), 0); |
| 3294 | 3953 | ||
| 3295 | CNIC_WR(dev, BAR_XSTRORM_INTMEM + | 3954 | CNIC_WR(dev, BAR_XSTRORM_INTMEM + |
| 3296 | XSTORM_TCP_GLOBAL_DEL_ACK_COUNTER_ENABLED_OFFSET(func), 1); | 3955 | XSTORM_TCP_GLOBAL_DEL_ACK_COUNTER_ENABLED_OFFSET(port), 1); |
| 3297 | CNIC_WR(dev, BAR_XSTRORM_INTMEM + | 3956 | CNIC_WR(dev, BAR_XSTRORM_INTMEM + |
| 3298 | XSTORM_TCP_GLOBAL_DEL_ACK_COUNTER_MAX_COUNT_OFFSET(func), | 3957 | XSTORM_TCP_GLOBAL_DEL_ACK_COUNTER_MAX_COUNT_OFFSET(port), |
| 3299 | DEF_MAX_DA_COUNT); | 3958 | DEF_MAX_DA_COUNT); |
| 3300 | 3959 | ||
| 3301 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + | 3960 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + |
| 3302 | XSTORM_ISCSI_TCP_VARS_TTL_OFFSET(func), DEF_TTL); | 3961 | XSTORM_ISCSI_TCP_VARS_TTL_OFFSET(pfid), DEF_TTL); |
| 3303 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + | 3962 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + |
| 3304 | XSTORM_ISCSI_TCP_VARS_TOS_OFFSET(func), DEF_TOS); | 3963 | XSTORM_ISCSI_TCP_VARS_TOS_OFFSET(pfid), DEF_TOS); |
| 3305 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + | 3964 | CNIC_WR8(dev, BAR_XSTRORM_INTMEM + |
| 3306 | XSTORM_ISCSI_TCP_VARS_ADV_WND_SCL_OFFSET(func), 2); | 3965 | XSTORM_ISCSI_TCP_VARS_ADV_WND_SCL_OFFSET(pfid), 2); |
| 3307 | CNIC_WR(dev, BAR_XSTRORM_INTMEM + | 3966 | CNIC_WR(dev, BAR_XSTRORM_INTMEM + |
| 3308 | XSTORM_TCP_TX_SWS_TIMER_VAL_OFFSET(func), DEF_SWS_TIMER); | 3967 | XSTORM_TCP_TX_SWS_TIMER_VAL_OFFSET(pfid), DEF_SWS_TIMER); |
| 3309 | 3968 | ||
| 3310 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + TSTORM_TCP_MAX_CWND_OFFSET(func), | 3969 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + TSTORM_TCP_MAX_CWND_OFFSET(pfid), |
| 3311 | DEF_MAX_CWND); | 3970 | DEF_MAX_CWND); |
| 3312 | return 0; | 3971 | return 0; |
| 3313 | } | 3972 | } |
| 3314 | 3973 | ||
| 3974 | static void cnic_delete_task(struct work_struct *work) | ||
| 3975 | { | ||
| 3976 | struct cnic_local *cp; | ||
| 3977 | struct cnic_dev *dev; | ||
| 3978 | u32 i; | ||
| 3979 | int need_resched = 0; | ||
| 3980 | |||
| 3981 | cp = container_of(work, struct cnic_local, delete_task.work); | ||
| 3982 | dev = cp->dev; | ||
| 3983 | |||
| 3984 | if (test_and_clear_bit(CNIC_LCL_FL_STOP_ISCSI, &cp->cnic_local_flags)) { | ||
| 3985 | struct drv_ctl_info info; | ||
| 3986 | |||
| 3987 | cnic_ulp_stop_one(cp, CNIC_ULP_ISCSI); | ||
| 3988 | |||
| 3989 | info.cmd = DRV_CTL_ISCSI_STOPPED_CMD; | ||
| 3990 | cp->ethdev->drv_ctl(dev->netdev, &info); | ||
| 3991 | } | ||
| 3992 | |||
| 3993 | for (i = 0; i < cp->max_cid_space; i++) { | ||
| 3994 | struct cnic_context *ctx = &cp->ctx_tbl[i]; | ||
| 3995 | |||
| 3996 | if (!test_bit(CTX_FL_OFFLD_START, &ctx->ctx_flags) || | ||
| 3997 | !test_bit(CTX_FL_DELETE_WAIT, &ctx->ctx_flags)) | ||
| 3998 | continue; | ||
| 3999 | |||
| 4000 | if (!time_after(jiffies, ctx->timestamp + (2 * HZ))) { | ||
| 4001 | need_resched = 1; | ||
| 4002 | continue; | ||
| 4003 | } | ||
| 4004 | |||
| 4005 | if (!test_and_clear_bit(CTX_FL_DELETE_WAIT, &ctx->ctx_flags)) | ||
| 4006 | continue; | ||
| 4007 | |||
| 4008 | cnic_bnx2x_destroy_ramrod(dev, i); | ||
| 4009 | |||
| 4010 | cnic_free_bnx2x_conn_resc(dev, i); | ||
| 4011 | if (ctx->ulp_proto_id == CNIC_ULP_ISCSI) | ||
| 4012 | atomic_dec(&cp->iscsi_conn); | ||
| 4013 | |||
| 4014 | clear_bit(CTX_FL_OFFLD_START, &ctx->ctx_flags); | ||
| 4015 | } | ||
| 4016 | |||
| 4017 | if (need_resched) | ||
| 4018 | queue_delayed_work(cnic_wq, &cp->delete_task, | ||
| 4019 | msecs_to_jiffies(10)); | ||
| 4020 | |||
| 4021 | } | ||
| 4022 | |||
| 3315 | static int cnic_cm_open(struct cnic_dev *dev) | 4023 | static int cnic_cm_open(struct cnic_dev *dev) |
| 3316 | { | 4024 | { |
| 3317 | struct cnic_local *cp = dev->cnic_priv; | 4025 | struct cnic_local *cp = dev->cnic_priv; |
| @@ -3326,6 +4034,8 @@ static int cnic_cm_open(struct cnic_dev *dev) | |||
| 3326 | if (err) | 4034 | if (err) |
| 3327 | goto err_out; | 4035 | goto err_out; |
| 3328 | 4036 | ||
| 4037 | INIT_DELAYED_WORK(&cp->delete_task, cnic_delete_task); | ||
| 4038 | |||
| 3329 | dev->cm_create = cnic_cm_create; | 4039 | dev->cm_create = cnic_cm_create; |
| 3330 | dev->cm_destroy = cnic_cm_destroy; | 4040 | dev->cm_destroy = cnic_cm_destroy; |
| 3331 | dev->cm_connect = cnic_cm_connect; | 4041 | dev->cm_connect = cnic_cm_connect; |
| @@ -3418,11 +4128,24 @@ static void cnic_free_irq(struct cnic_dev *dev) | |||
| 3418 | 4128 | ||
| 3419 | if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) { | 4129 | if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) { |
| 3420 | cp->disable_int_sync(dev); | 4130 | cp->disable_int_sync(dev); |
| 3421 | tasklet_disable(&cp->cnic_irq_task); | 4131 | tasklet_kill(&cp->cnic_irq_task); |
| 3422 | free_irq(ethdev->irq_arr[0].vector, dev); | 4132 | free_irq(ethdev->irq_arr[0].vector, dev); |
| 3423 | } | 4133 | } |
| 3424 | } | 4134 | } |
| 3425 | 4135 | ||
| 4136 | static int cnic_request_irq(struct cnic_dev *dev) | ||
| 4137 | { | ||
| 4138 | struct cnic_local *cp = dev->cnic_priv; | ||
| 4139 | struct cnic_eth_dev *ethdev = cp->ethdev; | ||
| 4140 | int err; | ||
| 4141 | |||
| 4142 | err = request_irq(ethdev->irq_arr[0].vector, cnic_irq, 0, "cnic", dev); | ||
| 4143 | if (err) | ||
| 4144 | tasklet_disable(&cp->cnic_irq_task); | ||
| 4145 | |||
| 4146 | return err; | ||
| 4147 | } | ||
| 4148 | |||
| 3426 | static int cnic_init_bnx2_irq(struct cnic_dev *dev) | 4149 | static int cnic_init_bnx2_irq(struct cnic_dev *dev) |
| 3427 | { | 4150 | { |
| 3428 | struct cnic_local *cp = dev->cnic_priv; | 4151 | struct cnic_local *cp = dev->cnic_priv; |
| @@ -3443,12 +4166,10 @@ static int cnic_init_bnx2_irq(struct cnic_dev *dev) | |||
| 3443 | cp->last_status_idx = cp->status_blk.bnx2->status_idx; | 4166 | cp->last_status_idx = cp->status_blk.bnx2->status_idx; |
| 3444 | tasklet_init(&cp->cnic_irq_task, cnic_service_bnx2_msix, | 4167 | tasklet_init(&cp->cnic_irq_task, cnic_service_bnx2_msix, |
| 3445 | (unsigned long) dev); | 4168 | (unsigned long) dev); |
| 3446 | err = request_irq(ethdev->irq_arr[0].vector, cnic_irq, 0, | 4169 | err = cnic_request_irq(dev); |
| 3447 | "cnic", dev); | 4170 | if (err) |
| 3448 | if (err) { | ||
| 3449 | tasklet_disable(&cp->cnic_irq_task); | ||
| 3450 | return err; | 4171 | return err; |
| 3451 | } | 4172 | |
| 3452 | while (cp->status_blk.bnx2->status_completion_producer_index && | 4173 | while (cp->status_blk.bnx2->status_completion_producer_index && |
| 3453 | i < 10) { | 4174 | i < 10) { |
| 3454 | CNIC_WR(dev, BNX2_HC_COALESCE_NOW, | 4175 | CNIC_WR(dev, BNX2_HC_COALESCE_NOW, |
| @@ -3497,6 +4218,14 @@ static void cnic_enable_bnx2_int(struct cnic_dev *dev) | |||
| 3497 | BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | cp->last_status_idx); | 4218 | BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | cp->last_status_idx); |
| 3498 | } | 4219 | } |
| 3499 | 4220 | ||
| 4221 | static void cnic_get_bnx2_iscsi_info(struct cnic_dev *dev) | ||
| 4222 | { | ||
| 4223 | u32 max_conn; | ||
| 4224 | |||
| 4225 | max_conn = cnic_reg_rd_ind(dev, BNX2_FW_MAX_ISCSI_CONN); | ||
| 4226 | dev->max_iscsi_conn = max_conn; | ||
| 4227 | } | ||
| 4228 | |||
| 3500 | static void cnic_disable_bnx2_int_sync(struct cnic_dev *dev) | 4229 | static void cnic_disable_bnx2_int_sync(struct cnic_dev *dev) |
| 3501 | { | 4230 | { |
| 3502 | struct cnic_local *cp = dev->cnic_priv; | 4231 | struct cnic_local *cp = dev->cnic_priv; |
| @@ -3515,11 +4244,12 @@ static void cnic_init_bnx2_tx_ring(struct cnic_dev *dev) | |||
| 3515 | { | 4244 | { |
| 3516 | struct cnic_local *cp = dev->cnic_priv; | 4245 | struct cnic_local *cp = dev->cnic_priv; |
| 3517 | struct cnic_eth_dev *ethdev = cp->ethdev; | 4246 | struct cnic_eth_dev *ethdev = cp->ethdev; |
| 4247 | struct cnic_uio_dev *udev = cp->udev; | ||
| 3518 | u32 cid_addr, tx_cid, sb_id; | 4248 | u32 cid_addr, tx_cid, sb_id; |
| 3519 | u32 val, offset0, offset1, offset2, offset3; | 4249 | u32 val, offset0, offset1, offset2, offset3; |
| 3520 | int i; | 4250 | int i; |
| 3521 | struct tx_bd *txbd; | 4251 | struct tx_bd *txbd; |
| 3522 | dma_addr_t buf_map; | 4252 | dma_addr_t buf_map, ring_map = udev->l2_ring_map; |
| 3523 | struct status_block *s_blk = cp->status_blk.gen; | 4253 | struct status_block *s_blk = cp->status_blk.gen; |
| 3524 | 4254 | ||
| 3525 | sb_id = cp->status_blk_num; | 4255 | sb_id = cp->status_blk_num; |
| @@ -3561,18 +4291,18 @@ static void cnic_init_bnx2_tx_ring(struct cnic_dev *dev) | |||
| 3561 | val = BNX2_L2CTX_CMD_TYPE_TYPE_L2 | (8 << 16); | 4291 | val = BNX2_L2CTX_CMD_TYPE_TYPE_L2 | (8 << 16); |
| 3562 | cnic_ctx_wr(dev, cid_addr, offset1, val); | 4292 | cnic_ctx_wr(dev, cid_addr, offset1, val); |
| 3563 | 4293 | ||
| 3564 | txbd = (struct tx_bd *) cp->l2_ring; | 4294 | txbd = (struct tx_bd *) udev->l2_ring; |
| 3565 | 4295 | ||
| 3566 | buf_map = cp->l2_buf_map; | 4296 | buf_map = udev->l2_buf_map; |
| 3567 | for (i = 0; i < MAX_TX_DESC_CNT; i++, txbd++) { | 4297 | for (i = 0; i < MAX_TX_DESC_CNT; i++, txbd++) { |
| 3568 | txbd->tx_bd_haddr_hi = (u64) buf_map >> 32; | 4298 | txbd->tx_bd_haddr_hi = (u64) buf_map >> 32; |
| 3569 | txbd->tx_bd_haddr_lo = (u64) buf_map & 0xffffffff; | 4299 | txbd->tx_bd_haddr_lo = (u64) buf_map & 0xffffffff; |
| 3570 | } | 4300 | } |
| 3571 | val = (u64) cp->l2_ring_map >> 32; | 4301 | val = (u64) ring_map >> 32; |
| 3572 | cnic_ctx_wr(dev, cid_addr, offset2, val); | 4302 | cnic_ctx_wr(dev, cid_addr, offset2, val); |
| 3573 | txbd->tx_bd_haddr_hi = val; | 4303 | txbd->tx_bd_haddr_hi = val; |
| 3574 | 4304 | ||
| 3575 | val = (u64) cp->l2_ring_map & 0xffffffff; | 4305 | val = (u64) ring_map & 0xffffffff; |
| 3576 | cnic_ctx_wr(dev, cid_addr, offset3, val); | 4306 | cnic_ctx_wr(dev, cid_addr, offset3, val); |
| 3577 | txbd->tx_bd_haddr_lo = val; | 4307 | txbd->tx_bd_haddr_lo = val; |
| 3578 | } | 4308 | } |
| @@ -3581,10 +4311,12 @@ static void cnic_init_bnx2_rx_ring(struct cnic_dev *dev) | |||
| 3581 | { | 4311 | { |
| 3582 | struct cnic_local *cp = dev->cnic_priv; | 4312 | struct cnic_local *cp = dev->cnic_priv; |
| 3583 | struct cnic_eth_dev *ethdev = cp->ethdev; | 4313 | struct cnic_eth_dev *ethdev = cp->ethdev; |
| 4314 | struct cnic_uio_dev *udev = cp->udev; | ||
| 3584 | u32 cid_addr, sb_id, val, coal_reg, coal_val; | 4315 | u32 cid_addr, sb_id, val, coal_reg, coal_val; |
| 3585 | int i; | 4316 | int i; |
| 3586 | struct rx_bd *rxbd; | 4317 | struct rx_bd *rxbd; |
| 3587 | struct status_block *s_blk = cp->status_blk.gen; | 4318 | struct status_block *s_blk = cp->status_blk.gen; |
| 4319 | dma_addr_t ring_map = udev->l2_ring_map; | ||
| 3588 | 4320 | ||
| 3589 | sb_id = cp->status_blk_num; | 4321 | sb_id = cp->status_blk_num; |
| 3590 | cnic_init_context(dev, 2); | 4322 | cnic_init_context(dev, 2); |
| @@ -3618,22 +4350,22 @@ static void cnic_init_bnx2_rx_ring(struct cnic_dev *dev) | |||
| 3618 | val = BNX2_L2CTX_L2_STATUSB_NUM(sb_id); | 4350 | val = BNX2_L2CTX_L2_STATUSB_NUM(sb_id); |
| 3619 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_HOST_BDIDX, val); | 4351 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_HOST_BDIDX, val); |
| 3620 | 4352 | ||
| 3621 | rxbd = (struct rx_bd *) (cp->l2_ring + BCM_PAGE_SIZE); | 4353 | rxbd = (struct rx_bd *) (udev->l2_ring + BCM_PAGE_SIZE); |
| 3622 | for (i = 0; i < MAX_RX_DESC_CNT; i++, rxbd++) { | 4354 | for (i = 0; i < MAX_RX_DESC_CNT; i++, rxbd++) { |
| 3623 | dma_addr_t buf_map; | 4355 | dma_addr_t buf_map; |
| 3624 | int n = (i % cp->l2_rx_ring_size) + 1; | 4356 | int n = (i % cp->l2_rx_ring_size) + 1; |
| 3625 | 4357 | ||
| 3626 | buf_map = cp->l2_buf_map + (n * cp->l2_single_buf_size); | 4358 | buf_map = udev->l2_buf_map + (n * cp->l2_single_buf_size); |
| 3627 | rxbd->rx_bd_len = cp->l2_single_buf_size; | 4359 | rxbd->rx_bd_len = cp->l2_single_buf_size; |
| 3628 | rxbd->rx_bd_flags = RX_BD_FLAGS_START | RX_BD_FLAGS_END; | 4360 | rxbd->rx_bd_flags = RX_BD_FLAGS_START | RX_BD_FLAGS_END; |
| 3629 | rxbd->rx_bd_haddr_hi = (u64) buf_map >> 32; | 4361 | rxbd->rx_bd_haddr_hi = (u64) buf_map >> 32; |
| 3630 | rxbd->rx_bd_haddr_lo = (u64) buf_map & 0xffffffff; | 4362 | rxbd->rx_bd_haddr_lo = (u64) buf_map & 0xffffffff; |
| 3631 | } | 4363 | } |
| 3632 | val = (u64) (cp->l2_ring_map + BCM_PAGE_SIZE) >> 32; | 4364 | val = (u64) (ring_map + BCM_PAGE_SIZE) >> 32; |
| 3633 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_NX_BDHADDR_HI, val); | 4365 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_NX_BDHADDR_HI, val); |
| 3634 | rxbd->rx_bd_haddr_hi = val; | 4366 | rxbd->rx_bd_haddr_hi = val; |
| 3635 | 4367 | ||
| 3636 | val = (u64) (cp->l2_ring_map + BCM_PAGE_SIZE) & 0xffffffff; | 4368 | val = (u64) (ring_map + BCM_PAGE_SIZE) & 0xffffffff; |
| 3637 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_NX_BDHADDR_LO, val); | 4369 | cnic_ctx_wr(dev, cid_addr, BNX2_L2CTX_NX_BDHADDR_LO, val); |
| 3638 | rxbd->rx_bd_haddr_lo = val; | 4370 | rxbd->rx_bd_haddr_lo = val; |
| 3639 | 4371 | ||
| @@ -3647,7 +4379,7 @@ static void cnic_shutdown_bnx2_rx_ring(struct cnic_dev *dev) | |||
| 3647 | 4379 | ||
| 3648 | memset(&l2kwqe, 0, sizeof(l2kwqe)); | 4380 | memset(&l2kwqe, 0, sizeof(l2kwqe)); |
| 3649 | wqes[0] = &l2kwqe; | 4381 | wqes[0] = &l2kwqe; |
| 3650 | l2kwqe.kwqe_op_flag = (L2_LAYER_CODE << KWQE_FLAGS_LAYER_SHIFT) | | 4382 | l2kwqe.kwqe_op_flag = (L2_LAYER_CODE << KWQE_LAYER_SHIFT) | |
| 3651 | (L2_KWQE_OPCODE_VALUE_FLUSH << | 4383 | (L2_KWQE_OPCODE_VALUE_FLUSH << |
| 3652 | KWQE_OPCODE_SHIFT) | 2; | 4384 | KWQE_OPCODE_SHIFT) | 2; |
| 3653 | dev->submit_kwqes(dev, wqes, 1); | 4385 | dev->submit_kwqes(dev, wqes, 1); |
| @@ -3818,6 +4550,8 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev) | |||
| 3818 | return err; | 4550 | return err; |
| 3819 | } | 4551 | } |
| 3820 | 4552 | ||
| 4553 | cnic_get_bnx2_iscsi_info(dev); | ||
| 4554 | |||
| 3821 | return 0; | 4555 | return 0; |
| 3822 | } | 4556 | } |
| 3823 | 4557 | ||
| @@ -3850,50 +4584,63 @@ static int cnic_init_bnx2x_irq(struct cnic_dev *dev) | |||
| 3850 | 4584 | ||
| 3851 | tasklet_init(&cp->cnic_irq_task, cnic_service_bnx2x_bh, | 4585 | tasklet_init(&cp->cnic_irq_task, cnic_service_bnx2x_bh, |
| 3852 | (unsigned long) dev); | 4586 | (unsigned long) dev); |
| 3853 | if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) { | 4587 | if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) |
| 3854 | err = request_irq(ethdev->irq_arr[0].vector, cnic_irq, 0, | 4588 | err = cnic_request_irq(dev); |
| 3855 | "cnic", dev); | 4589 | |
| 3856 | if (err) | ||
| 3857 | tasklet_disable(&cp->cnic_irq_task); | ||
| 3858 | } | ||
| 3859 | return err; | 4590 | return err; |
| 3860 | } | 4591 | } |
| 3861 | 4592 | ||
| 4593 | static inline void cnic_storm_memset_hc_disable(struct cnic_dev *dev, | ||
| 4594 | u16 sb_id, u8 sb_index, | ||
| 4595 | u8 disable) | ||
| 4596 | { | ||
| 4597 | |||
| 4598 | u32 addr = BAR_CSTRORM_INTMEM + | ||
| 4599 | CSTORM_STATUS_BLOCK_DATA_OFFSET(sb_id) + | ||
| 4600 | offsetof(struct hc_status_block_data_e1x, index_data) + | ||
| 4601 | sizeof(struct hc_index_data)*sb_index + | ||
| 4602 | offsetof(struct hc_index_data, flags); | ||
| 4603 | u16 flags = CNIC_RD16(dev, addr); | ||
| 4604 | /* clear and set */ | ||
| 4605 | flags &= ~HC_INDEX_DATA_HC_ENABLED; | ||
| 4606 | flags |= (((~disable) << HC_INDEX_DATA_HC_ENABLED_SHIFT) & | ||
| 4607 | HC_INDEX_DATA_HC_ENABLED); | ||
| 4608 | CNIC_WR16(dev, addr, flags); | ||
| 4609 | } | ||
| 4610 | |||
| 3862 | static void cnic_enable_bnx2x_int(struct cnic_dev *dev) | 4611 | static void cnic_enable_bnx2x_int(struct cnic_dev *dev) |
| 3863 | { | 4612 | { |
| 3864 | struct cnic_local *cp = dev->cnic_priv; | 4613 | struct cnic_local *cp = dev->cnic_priv; |
| 3865 | u8 sb_id = cp->status_blk_num; | 4614 | u8 sb_id = cp->status_blk_num; |
| 3866 | int port = CNIC_PORT(cp); | ||
| 3867 | 4615 | ||
| 3868 | CNIC_WR8(dev, BAR_CSTRORM_INTMEM + | 4616 | CNIC_WR8(dev, BAR_CSTRORM_INTMEM + |
| 3869 | CSTORM_SB_HC_TIMEOUT_C_OFFSET(port, sb_id, | 4617 | CSTORM_STATUS_BLOCK_DATA_OFFSET(sb_id) + |
| 3870 | HC_INDEX_C_ISCSI_EQ_CONS), | 4618 | offsetof(struct hc_status_block_data_e1x, index_data) + |
| 3871 | 64 / 12); | 4619 | sizeof(struct hc_index_data)*HC_INDEX_ISCSI_EQ_CONS + |
| 3872 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + | 4620 | offsetof(struct hc_index_data, timeout), 64 / 12); |
| 3873 | CSTORM_SB_HC_DISABLE_C_OFFSET(port, sb_id, | 4621 | cnic_storm_memset_hc_disable(dev, sb_id, HC_INDEX_ISCSI_EQ_CONS, 0); |
| 3874 | HC_INDEX_C_ISCSI_EQ_CONS), 0); | ||
| 3875 | } | 4622 | } |
| 3876 | 4623 | ||
| 3877 | static void cnic_disable_bnx2x_int_sync(struct cnic_dev *dev) | 4624 | static void cnic_disable_bnx2x_int_sync(struct cnic_dev *dev) |
| 3878 | { | 4625 | { |
| 3879 | } | 4626 | } |
| 3880 | 4627 | ||
| 3881 | static void cnic_init_bnx2x_tx_ring(struct cnic_dev *dev) | 4628 | static void cnic_init_bnx2x_tx_ring(struct cnic_dev *dev, |
| 4629 | struct client_init_ramrod_data *data) | ||
| 3882 | { | 4630 | { |
| 3883 | struct cnic_local *cp = dev->cnic_priv; | 4631 | struct cnic_local *cp = dev->cnic_priv; |
| 3884 | union eth_tx_bd_types *txbd = (union eth_tx_bd_types *) cp->l2_ring; | 4632 | struct cnic_uio_dev *udev = cp->udev; |
| 3885 | struct eth_context *context; | 4633 | union eth_tx_bd_types *txbd = (union eth_tx_bd_types *) udev->l2_ring; |
| 3886 | struct regpair context_addr; | 4634 | dma_addr_t buf_map, ring_map = udev->l2_ring_map; |
| 3887 | dma_addr_t buf_map; | 4635 | struct host_sp_status_block *sb = cp->bnx2x_def_status_blk; |
| 3888 | int func = CNIC_FUNC(cp); | ||
| 3889 | int port = CNIC_PORT(cp); | 4636 | int port = CNIC_PORT(cp); |
| 3890 | int i; | 4637 | int i; |
| 3891 | int cli = BNX2X_ISCSI_CL_ID(CNIC_E1HVN(cp)); | 4638 | u32 cli = cp->ethdev->iscsi_l2_client_id; |
| 3892 | u32 val; | 4639 | u32 val; |
| 3893 | 4640 | ||
| 3894 | memset(txbd, 0, BCM_PAGE_SIZE); | 4641 | memset(txbd, 0, BCM_PAGE_SIZE); |
| 3895 | 4642 | ||
| 3896 | buf_map = cp->l2_buf_map; | 4643 | buf_map = udev->l2_buf_map; |
| 3897 | for (i = 0; i < MAX_TX_DESC_CNT; i += 3, txbd += 3) { | 4644 | for (i = 0; i < MAX_TX_DESC_CNT; i += 3, txbd += 3) { |
| 3898 | struct eth_tx_start_bd *start_bd = &txbd->start_bd; | 4645 | struct eth_tx_start_bd *start_bd = &txbd->start_bd; |
| 3899 | struct eth_tx_bd *reg_bd = &((txbd + 2)->reg_bd); | 4646 | struct eth_tx_bd *reg_bd = &((txbd + 2)->reg_bd); |
| @@ -3910,33 +4657,23 @@ static void cnic_init_bnx2x_tx_ring(struct cnic_dev *dev) | |||
| 3910 | start_bd->general_data |= (1 << ETH_TX_START_BD_HDR_NBDS_SHIFT); | 4657 | start_bd->general_data |= (1 << ETH_TX_START_BD_HDR_NBDS_SHIFT); |
| 3911 | 4658 | ||
| 3912 | } | 4659 | } |
| 3913 | context = cnic_get_bnx2x_ctx(dev, BNX2X_ISCSI_L2_CID, 1, &context_addr); | ||
| 3914 | 4660 | ||
| 3915 | val = (u64) cp->l2_ring_map >> 32; | 4661 | val = (u64) ring_map >> 32; |
| 3916 | txbd->next_bd.addr_hi = cpu_to_le32(val); | 4662 | txbd->next_bd.addr_hi = cpu_to_le32(val); |
| 3917 | 4663 | ||
| 3918 | context->xstorm_st_context.tx_bd_page_base_hi = val; | 4664 | data->tx.tx_bd_page_base.hi = cpu_to_le32(val); |
| 3919 | 4665 | ||
| 3920 | val = (u64) cp->l2_ring_map & 0xffffffff; | 4666 | val = (u64) ring_map & 0xffffffff; |
| 3921 | txbd->next_bd.addr_lo = cpu_to_le32(val); | 4667 | txbd->next_bd.addr_lo = cpu_to_le32(val); |
| 3922 | 4668 | ||
| 3923 | context->xstorm_st_context.tx_bd_page_base_lo = val; | 4669 | data->tx.tx_bd_page_base.lo = cpu_to_le32(val); |
| 3924 | |||
| 3925 | context->cstorm_st_context.sb_index_number = | ||
| 3926 | HC_INDEX_DEF_C_ETH_ISCSI_CQ_CONS; | ||
| 3927 | context->cstorm_st_context.status_block_id = BNX2X_DEF_SB_ID; | ||
| 3928 | 4670 | ||
| 3929 | if (cli < MAX_X_STAT_COUNTER_ID) | 4671 | /* Other ramrod params */ |
| 3930 | context->xstorm_st_context.statistics_data = cli | | 4672 | data->tx.tx_sb_index_number = HC_SP_INDEX_ETH_ISCSI_CQ_CONS; |
| 3931 | XSTORM_ETH_ST_CONTEXT_STATISTICS_ENABLE; | 4673 | data->tx.tx_status_block_id = BNX2X_DEF_SB_ID; |
| 3932 | |||
| 3933 | context->xstorm_ag_context.cdu_reserved = | ||
| 3934 | CDU_RSRVD_VALUE_TYPE_A(BNX2X_HW_CID(BNX2X_ISCSI_L2_CID, func), | ||
| 3935 | CDU_REGION_NUMBER_XCM_AG, | ||
| 3936 | ETH_CONNECTION_TYPE); | ||
| 3937 | 4674 | ||
| 3938 | /* reset xstorm per client statistics */ | 4675 | /* reset xstorm per client statistics */ |
| 3939 | if (cli < MAX_X_STAT_COUNTER_ID) { | 4676 | if (cli < MAX_STAT_COUNTER_ID) { |
| 3940 | val = BAR_XSTRORM_INTMEM + | 4677 | val = BAR_XSTRORM_INTMEM + |
| 3941 | XSTORM_PER_COUNTER_ID_STATS_OFFSET(port, cli); | 4678 | XSTORM_PER_COUNTER_ID_STATS_OFFSET(port, cli); |
| 3942 | for (i = 0; i < sizeof(struct xstorm_per_client_stats) / 4; i++) | 4679 | for (i = 0; i < sizeof(struct xstorm_per_client_stats) / 4; i++) |
| @@ -3944,111 +4681,77 @@ static void cnic_init_bnx2x_tx_ring(struct cnic_dev *dev) | |||
| 3944 | } | 4681 | } |
| 3945 | 4682 | ||
| 3946 | cp->tx_cons_ptr = | 4683 | cp->tx_cons_ptr = |
| 3947 | &cp->bnx2x_def_status_blk->c_def_status_block.index_values[ | 4684 | &sb->sp_sb.index_values[HC_SP_INDEX_ETH_ISCSI_CQ_CONS]; |
| 3948 | HC_INDEX_DEF_C_ETH_ISCSI_CQ_CONS]; | ||
| 3949 | } | 4685 | } |
| 3950 | 4686 | ||
| 3951 | static void cnic_init_bnx2x_rx_ring(struct cnic_dev *dev) | 4687 | static void cnic_init_bnx2x_rx_ring(struct cnic_dev *dev, |
| 4688 | struct client_init_ramrod_data *data) | ||
| 3952 | { | 4689 | { |
| 3953 | struct cnic_local *cp = dev->cnic_priv; | 4690 | struct cnic_local *cp = dev->cnic_priv; |
| 3954 | struct eth_rx_bd *rxbd = (struct eth_rx_bd *) (cp->l2_ring + | 4691 | struct cnic_uio_dev *udev = cp->udev; |
| 4692 | struct eth_rx_bd *rxbd = (struct eth_rx_bd *) (udev->l2_ring + | ||
| 3955 | BCM_PAGE_SIZE); | 4693 | BCM_PAGE_SIZE); |
| 3956 | struct eth_rx_cqe_next_page *rxcqe = (struct eth_rx_cqe_next_page *) | 4694 | struct eth_rx_cqe_next_page *rxcqe = (struct eth_rx_cqe_next_page *) |
| 3957 | (cp->l2_ring + (2 * BCM_PAGE_SIZE)); | 4695 | (udev->l2_ring + (2 * BCM_PAGE_SIZE)); |
| 3958 | struct eth_context *context; | 4696 | struct host_sp_status_block *sb = cp->bnx2x_def_status_blk; |
| 3959 | struct regpair context_addr; | ||
| 3960 | int i; | 4697 | int i; |
| 3961 | int port = CNIC_PORT(cp); | 4698 | int port = CNIC_PORT(cp); |
| 3962 | int func = CNIC_FUNC(cp); | 4699 | u32 cli = cp->ethdev->iscsi_l2_client_id; |
| 3963 | int cli = BNX2X_ISCSI_CL_ID(CNIC_E1HVN(cp)); | 4700 | int cl_qzone_id = BNX2X_CL_QZONE_ID(cp, cli); |
| 3964 | u32 val; | 4701 | u32 val; |
| 3965 | struct tstorm_eth_client_config tstorm_client = {0}; | 4702 | dma_addr_t ring_map = udev->l2_ring_map; |
| 4703 | |||
| 4704 | /* General data */ | ||
| 4705 | data->general.client_id = cli; | ||
| 4706 | data->general.statistics_en_flg = 1; | ||
| 4707 | data->general.statistics_counter_id = cli; | ||
| 4708 | data->general.activate_flg = 1; | ||
| 4709 | data->general.sp_client_id = cli; | ||
| 3966 | 4710 | ||
| 3967 | for (i = 0; i < BNX2X_MAX_RX_DESC_CNT; i++, rxbd++) { | 4711 | for (i = 0; i < BNX2X_MAX_RX_DESC_CNT; i++, rxbd++) { |
| 3968 | dma_addr_t buf_map; | 4712 | dma_addr_t buf_map; |
| 3969 | int n = (i % cp->l2_rx_ring_size) + 1; | 4713 | int n = (i % cp->l2_rx_ring_size) + 1; |
| 3970 | 4714 | ||
| 3971 | buf_map = cp->l2_buf_map + (n * cp->l2_single_buf_size); | 4715 | buf_map = udev->l2_buf_map + (n * cp->l2_single_buf_size); |
| 3972 | rxbd->addr_hi = cpu_to_le32((u64) buf_map >> 32); | 4716 | rxbd->addr_hi = cpu_to_le32((u64) buf_map >> 32); |
| 3973 | rxbd->addr_lo = cpu_to_le32(buf_map & 0xffffffff); | 4717 | rxbd->addr_lo = cpu_to_le32(buf_map & 0xffffffff); |
| 3974 | } | 4718 | } |
| 3975 | context = cnic_get_bnx2x_ctx(dev, BNX2X_ISCSI_L2_CID, 0, &context_addr); | ||
| 3976 | 4719 | ||
| 3977 | val = (u64) (cp->l2_ring_map + BCM_PAGE_SIZE) >> 32; | 4720 | val = (u64) (ring_map + BCM_PAGE_SIZE) >> 32; |
| 3978 | rxbd->addr_hi = cpu_to_le32(val); | 4721 | rxbd->addr_hi = cpu_to_le32(val); |
| 4722 | data->rx.bd_page_base.hi = cpu_to_le32(val); | ||
| 3979 | 4723 | ||
| 3980 | context->ustorm_st_context.common.bd_page_base_hi = val; | 4724 | val = (u64) (ring_map + BCM_PAGE_SIZE) & 0xffffffff; |
| 3981 | |||
| 3982 | val = (u64) (cp->l2_ring_map + BCM_PAGE_SIZE) & 0xffffffff; | ||
| 3983 | rxbd->addr_lo = cpu_to_le32(val); | 4725 | rxbd->addr_lo = cpu_to_le32(val); |
| 3984 | 4726 | data->rx.bd_page_base.lo = cpu_to_le32(val); | |
| 3985 | context->ustorm_st_context.common.bd_page_base_lo = val; | ||
| 3986 | |||
| 3987 | context->ustorm_st_context.common.sb_index_numbers = | ||
| 3988 | BNX2X_ISCSI_RX_SB_INDEX_NUM; | ||
| 3989 | context->ustorm_st_context.common.clientId = cli; | ||
| 3990 | context->ustorm_st_context.common.status_block_id = BNX2X_DEF_SB_ID; | ||
| 3991 | if (cli < MAX_U_STAT_COUNTER_ID) { | ||
| 3992 | context->ustorm_st_context.common.flags = | ||
| 3993 | USTORM_ETH_ST_CONTEXT_CONFIG_ENABLE_STATISTICS; | ||
| 3994 | context->ustorm_st_context.common.statistics_counter_id = cli; | ||
| 3995 | } | ||
| 3996 | context->ustorm_st_context.common.mc_alignment_log_size = 0; | ||
| 3997 | context->ustorm_st_context.common.bd_buff_size = | ||
| 3998 | cp->l2_single_buf_size; | ||
| 3999 | |||
| 4000 | context->ustorm_ag_context.cdu_usage = | ||
| 4001 | CDU_RSRVD_VALUE_TYPE_A(BNX2X_HW_CID(BNX2X_ISCSI_L2_CID, func), | ||
| 4002 | CDU_REGION_NUMBER_UCM_AG, | ||
| 4003 | ETH_CONNECTION_TYPE); | ||
| 4004 | 4727 | ||
| 4005 | rxcqe += BNX2X_MAX_RCQ_DESC_CNT; | 4728 | rxcqe += BNX2X_MAX_RCQ_DESC_CNT; |
| 4006 | val = (u64) (cp->l2_ring_map + (2 * BCM_PAGE_SIZE)) >> 32; | 4729 | val = (u64) (ring_map + (2 * BCM_PAGE_SIZE)) >> 32; |
| 4007 | rxcqe->addr_hi = cpu_to_le32(val); | 4730 | rxcqe->addr_hi = cpu_to_le32(val); |
| 4731 | data->rx.cqe_page_base.hi = cpu_to_le32(val); | ||
| 4008 | 4732 | ||
| 4009 | CNIC_WR(dev, BAR_USTRORM_INTMEM + | 4733 | val = (u64) (ring_map + (2 * BCM_PAGE_SIZE)) & 0xffffffff; |
| 4010 | USTORM_CQE_PAGE_BASE_OFFSET(port, cli) + 4, val); | ||
| 4011 | |||
| 4012 | CNIC_WR(dev, BAR_USTRORM_INTMEM + | ||
| 4013 | USTORM_CQE_PAGE_NEXT_OFFSET(port, cli) + 4, val); | ||
| 4014 | |||
| 4015 | val = (u64) (cp->l2_ring_map + (2 * BCM_PAGE_SIZE)) & 0xffffffff; | ||
| 4016 | rxcqe->addr_lo = cpu_to_le32(val); | 4734 | rxcqe->addr_lo = cpu_to_le32(val); |
| 4735 | data->rx.cqe_page_base.lo = cpu_to_le32(val); | ||
| 4017 | 4736 | ||
| 4018 | CNIC_WR(dev, BAR_USTRORM_INTMEM + | 4737 | /* Other ramrod params */ |
| 4019 | USTORM_CQE_PAGE_BASE_OFFSET(port, cli), val); | 4738 | data->rx.client_qzone_id = cl_qzone_id; |
| 4739 | data->rx.rx_sb_index_number = HC_SP_INDEX_ETH_ISCSI_RX_CQ_CONS; | ||
| 4740 | data->rx.status_block_id = BNX2X_DEF_SB_ID; | ||
| 4020 | 4741 | ||
| 4021 | CNIC_WR(dev, BAR_USTRORM_INTMEM + | 4742 | data->rx.cache_line_alignment_log_size = L1_CACHE_SHIFT; |
| 4022 | USTORM_CQE_PAGE_NEXT_OFFSET(port, cli), val); | 4743 | data->rx.bd_buff_size = cpu_to_le16(cp->l2_single_buf_size); |
| 4023 | 4744 | ||
| 4024 | /* client tstorm info */ | 4745 | data->rx.mtu = cpu_to_le16(cp->l2_single_buf_size - 14); |
| 4025 | tstorm_client.mtu = cp->l2_single_buf_size - 14; | 4746 | data->rx.outer_vlan_removal_enable_flg = 1; |
| 4026 | tstorm_client.config_flags = TSTORM_ETH_CLIENT_CONFIG_E1HOV_REM_ENABLE; | ||
| 4027 | |||
| 4028 | if (cli < MAX_T_STAT_COUNTER_ID) { | ||
| 4029 | tstorm_client.config_flags |= | ||
| 4030 | TSTORM_ETH_CLIENT_CONFIG_STATSITICS_ENABLE; | ||
| 4031 | tstorm_client.statistics_counter_id = cli; | ||
| 4032 | } | ||
| 4033 | |||
| 4034 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + | ||
| 4035 | TSTORM_CLIENT_CONFIG_OFFSET(port, cli), | ||
| 4036 | ((u32 *)&tstorm_client)[0]); | ||
| 4037 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + | ||
| 4038 | TSTORM_CLIENT_CONFIG_OFFSET(port, cli) + 4, | ||
| 4039 | ((u32 *)&tstorm_client)[1]); | ||
| 4040 | |||
| 4041 | /* reset tstorm per client statistics */ | ||
| 4042 | if (cli < MAX_T_STAT_COUNTER_ID) { | ||
| 4043 | 4747 | ||
| 4748 | /* reset tstorm and ustorm per client statistics */ | ||
| 4749 | if (cli < MAX_STAT_COUNTER_ID) { | ||
| 4044 | val = BAR_TSTRORM_INTMEM + | 4750 | val = BAR_TSTRORM_INTMEM + |
| 4045 | TSTORM_PER_COUNTER_ID_STATS_OFFSET(port, cli); | 4751 | TSTORM_PER_COUNTER_ID_STATS_OFFSET(port, cli); |
| 4046 | for (i = 0; i < sizeof(struct tstorm_per_client_stats) / 4; i++) | 4752 | for (i = 0; i < sizeof(struct tstorm_per_client_stats) / 4; i++) |
| 4047 | CNIC_WR(dev, val + i * 4, 0); | 4753 | CNIC_WR(dev, val + i * 4, 0); |
| 4048 | } | ||
| 4049 | 4754 | ||
| 4050 | /* reset ustorm per client statistics */ | ||
| 4051 | if (cli < MAX_U_STAT_COUNTER_ID) { | ||
| 4052 | val = BAR_USTRORM_INTMEM + | 4755 | val = BAR_USTRORM_INTMEM + |
| 4053 | USTORM_PER_COUNTER_ID_STATS_OFFSET(port, cli); | 4756 | USTORM_PER_COUNTER_ID_STATS_OFFSET(port, cli); |
| 4054 | for (i = 0; i < sizeof(struct ustorm_per_client_stats) / 4; i++) | 4757 | for (i = 0; i < sizeof(struct ustorm_per_client_stats) / 4; i++) |
| @@ -4056,78 +4759,71 @@ static void cnic_init_bnx2x_rx_ring(struct cnic_dev *dev) | |||
| 4056 | } | 4759 | } |
| 4057 | 4760 | ||
| 4058 | cp->rx_cons_ptr = | 4761 | cp->rx_cons_ptr = |
| 4059 | &cp->bnx2x_def_status_blk->u_def_status_block.index_values[ | 4762 | &sb->sp_sb.index_values[HC_SP_INDEX_ETH_ISCSI_RX_CQ_CONS]; |
| 4060 | HC_INDEX_DEF_U_ETH_ISCSI_RX_CQ_CONS]; | 4763 | cp->rx_cons = *cp->rx_cons_ptr; |
| 4061 | } | 4764 | } |
| 4062 | 4765 | ||
| 4063 | static void cnic_get_bnx2x_iscsi_info(struct cnic_dev *dev) | 4766 | static void cnic_init_bnx2x_kcq(struct cnic_dev *dev) |
| 4064 | { | 4767 | { |
| 4065 | struct cnic_local *cp = dev->cnic_priv; | 4768 | struct cnic_local *cp = dev->cnic_priv; |
| 4066 | u32 base, addr, val; | 4769 | u32 pfid = cp->pfid; |
| 4067 | int port = CNIC_PORT(cp); | ||
| 4068 | 4770 | ||
| 4069 | dev->max_iscsi_conn = 0; | 4771 | cp->kcq1.io_addr = BAR_CSTRORM_INTMEM + |
| 4070 | base = CNIC_RD(dev, MISC_REG_SHARED_MEM_ADDR); | 4772 | CSTORM_ISCSI_EQ_PROD_OFFSET(pfid, 0); |
| 4071 | if (base < 0xa0000 || base >= 0xc0000) | 4773 | cp->kcq1.sw_prod_idx = 0; |
| 4072 | return; | ||
| 4073 | |||
| 4074 | addr = BNX2X_SHMEM_ADDR(base, | ||
| 4075 | dev_info.port_hw_config[port].iscsi_mac_upper); | ||
| 4076 | 4774 | ||
| 4077 | val = CNIC_RD(dev, addr); | 4775 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { |
| 4776 | struct host_hc_status_block_e2 *sb = cp->status_blk.gen; | ||
| 4078 | 4777 | ||
| 4079 | dev->mac_addr[0] = (u8) (val >> 8); | 4778 | cp->kcq1.hw_prod_idx_ptr = |
| 4080 | dev->mac_addr[1] = (u8) val; | 4779 | &sb->sb.index_values[HC_INDEX_ISCSI_EQ_CONS]; |
| 4081 | 4780 | cp->kcq1.status_idx_ptr = | |
| 4082 | addr = BNX2X_SHMEM_ADDR(base, | 4781 | &sb->sb.running_index[SM_RX_ID]; |
| 4083 | dev_info.port_hw_config[port].iscsi_mac_lower); | 4782 | } else { |
| 4783 | struct host_hc_status_block_e1x *sb = cp->status_blk.gen; | ||
| 4084 | 4784 | ||
| 4085 | val = CNIC_RD(dev, addr); | 4785 | cp->kcq1.hw_prod_idx_ptr = |
| 4786 | &sb->sb.index_values[HC_INDEX_ISCSI_EQ_CONS]; | ||
| 4787 | cp->kcq1.status_idx_ptr = | ||
| 4788 | &sb->sb.running_index[SM_RX_ID]; | ||
| 4789 | } | ||
| 4086 | 4790 | ||
| 4087 | dev->mac_addr[2] = (u8) (val >> 24); | 4791 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { |
| 4088 | dev->mac_addr[3] = (u8) (val >> 16); | 4792 | struct host_hc_status_block_e2 *sb = cp->status_blk.gen; |
| 4089 | dev->mac_addr[4] = (u8) (val >> 8); | ||
| 4090 | dev->mac_addr[5] = (u8) val; | ||
| 4091 | 4793 | ||
| 4092 | addr = BNX2X_SHMEM_ADDR(base, validity_map[port]); | 4794 | cp->kcq2.io_addr = BAR_USTRORM_INTMEM + |
| 4093 | val = CNIC_RD(dev, addr); | 4795 | USTORM_FCOE_EQ_PROD_OFFSET(pfid); |
| 4094 | 4796 | cp->kcq2.sw_prod_idx = 0; | |
| 4095 | if (!(val & SHR_MEM_VALIDITY_LIC_NO_KEY_IN_EFFECT)) { | 4797 | cp->kcq2.hw_prod_idx_ptr = |
| 4096 | u16 val16; | 4798 | &sb->sb.index_values[HC_INDEX_FCOE_EQ_CONS]; |
| 4097 | 4799 | cp->kcq2.status_idx_ptr = | |
| 4098 | addr = BNX2X_SHMEM_ADDR(base, | 4800 | &sb->sb.running_index[SM_RX_ID]; |
| 4099 | drv_lic_key[port].max_iscsi_init_conn); | ||
| 4100 | val16 = CNIC_RD16(dev, addr); | ||
| 4101 | |||
| 4102 | if (val16) | ||
| 4103 | val16 ^= 0x1e1e; | ||
| 4104 | dev->max_iscsi_conn = val16; | ||
| 4105 | } | ||
| 4106 | if (BNX2X_CHIP_IS_E1H(cp->chip_id)) { | ||
| 4107 | int func = CNIC_FUNC(cp); | ||
| 4108 | |||
| 4109 | addr = BNX2X_SHMEM_ADDR(base, | ||
| 4110 | mf_cfg.func_mf_config[func].e1hov_tag); | ||
| 4111 | val = CNIC_RD(dev, addr); | ||
| 4112 | val &= FUNC_MF_CFG_E1HOV_TAG_MASK; | ||
| 4113 | if (val != FUNC_MF_CFG_E1HOV_TAG_DEFAULT) { | ||
| 4114 | addr = BNX2X_SHMEM_ADDR(base, | ||
| 4115 | mf_cfg.func_mf_config[func].config); | ||
| 4116 | val = CNIC_RD(dev, addr); | ||
| 4117 | val &= FUNC_MF_CFG_PROTOCOL_MASK; | ||
| 4118 | if (val != FUNC_MF_CFG_PROTOCOL_ISCSI) | ||
| 4119 | dev->max_iscsi_conn = 0; | ||
| 4120 | } | ||
| 4121 | } | 4801 | } |
| 4122 | } | 4802 | } |
| 4123 | 4803 | ||
| 4124 | static int cnic_start_bnx2x_hw(struct cnic_dev *dev) | 4804 | static int cnic_start_bnx2x_hw(struct cnic_dev *dev) |
| 4125 | { | 4805 | { |
| 4126 | struct cnic_local *cp = dev->cnic_priv; | 4806 | struct cnic_local *cp = dev->cnic_priv; |
| 4807 | struct cnic_eth_dev *ethdev = cp->ethdev; | ||
| 4127 | int func = CNIC_FUNC(cp), ret, i; | 4808 | int func = CNIC_FUNC(cp), ret, i; |
| 4128 | int port = CNIC_PORT(cp); | 4809 | u32 pfid; |
| 4129 | u16 eq_idx; | 4810 | |
| 4130 | u8 sb_id = cp->status_blk_num; | 4811 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { |
| 4812 | u32 val = CNIC_RD(dev, MISC_REG_PORT4MODE_EN_OVWR); | ||
| 4813 | |||
| 4814 | if (!(val & 1)) | ||
| 4815 | val = CNIC_RD(dev, MISC_REG_PORT4MODE_EN); | ||
| 4816 | else | ||
| 4817 | val = (val >> 1) & 1; | ||
| 4818 | |||
| 4819 | if (val) | ||
| 4820 | cp->pfid = func >> 1; | ||
| 4821 | else | ||
| 4822 | cp->pfid = func & 0x6; | ||
| 4823 | } else { | ||
| 4824 | cp->pfid = func; | ||
| 4825 | } | ||
| 4826 | pfid = cp->pfid; | ||
| 4131 | 4827 | ||
| 4132 | ret = cnic_init_id_tbl(&cp->cid_tbl, MAX_ISCSI_TBL_SZ, | 4828 | ret = cnic_init_id_tbl(&cp->cid_tbl, MAX_ISCSI_TBL_SZ, |
| 4133 | cp->iscsi_start_cid); | 4829 | cp->iscsi_start_cid); |
| @@ -4135,86 +4831,88 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev) | |||
| 4135 | if (ret) | 4831 | if (ret) |
| 4136 | return -ENOMEM; | 4832 | return -ENOMEM; |
| 4137 | 4833 | ||
| 4138 | cp->kcq1.io_addr = BAR_CSTRORM_INTMEM + | 4834 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) { |
| 4139 | CSTORM_ISCSI_EQ_PROD_OFFSET(func, 0); | 4835 | ret = cnic_init_id_tbl(&cp->fcoe_cid_tbl, |
| 4140 | cp->kcq1.sw_prod_idx = 0; | 4836 | BNX2X_FCOE_NUM_CONNECTIONS, |
| 4837 | cp->fcoe_start_cid); | ||
| 4141 | 4838 | ||
| 4142 | cp->kcq1.hw_prod_idx_ptr = | 4839 | if (ret) |
| 4143 | &cp->status_blk.bnx2x->c_status_block.index_values[ | 4840 | return -ENOMEM; |
| 4144 | HC_INDEX_C_ISCSI_EQ_CONS]; | 4841 | } |
| 4145 | cp->kcq1.status_idx_ptr = | ||
| 4146 | &cp->status_blk.bnx2x->c_status_block.status_block_index; | ||
| 4147 | 4842 | ||
| 4148 | cnic_get_bnx2x_iscsi_info(dev); | 4843 | cp->bnx2x_igu_sb_id = ethdev->irq_arr[0].status_blk_num2; |
| 4844 | |||
| 4845 | cnic_init_bnx2x_kcq(dev); | ||
| 4149 | 4846 | ||
| 4150 | /* Only 1 EQ */ | 4847 | /* Only 1 EQ */ |
| 4151 | CNIC_WR16(dev, cp->kcq1.io_addr, MAX_KCQ_IDX); | 4848 | CNIC_WR16(dev, cp->kcq1.io_addr, MAX_KCQ_IDX); |
| 4152 | CNIC_WR(dev, BAR_CSTRORM_INTMEM + | 4849 | CNIC_WR(dev, BAR_CSTRORM_INTMEM + |
| 4153 | CSTORM_ISCSI_EQ_CONS_OFFSET(func, 0), 0); | 4850 | CSTORM_ISCSI_EQ_CONS_OFFSET(pfid, 0), 0); |
| 4154 | CNIC_WR(dev, BAR_CSTRORM_INTMEM + | 4851 | CNIC_WR(dev, BAR_CSTRORM_INTMEM + |
| 4155 | CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_OFFSET(func, 0), | 4852 | CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_OFFSET(pfid, 0), |
| 4156 | cp->kcq1.dma.pg_map_arr[1] & 0xffffffff); | 4853 | cp->kcq1.dma.pg_map_arr[1] & 0xffffffff); |
| 4157 | CNIC_WR(dev, BAR_CSTRORM_INTMEM + | 4854 | CNIC_WR(dev, BAR_CSTRORM_INTMEM + |
| 4158 | CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_OFFSET(func, 0) + 4, | 4855 | CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_OFFSET(pfid, 0) + 4, |
| 4159 | (u64) cp->kcq1.dma.pg_map_arr[1] >> 32); | 4856 | (u64) cp->kcq1.dma.pg_map_arr[1] >> 32); |
| 4160 | CNIC_WR(dev, BAR_CSTRORM_INTMEM + | 4857 | CNIC_WR(dev, BAR_CSTRORM_INTMEM + |
| 4161 | CSTORM_ISCSI_EQ_NEXT_EQE_ADDR_OFFSET(func, 0), | 4858 | CSTORM_ISCSI_EQ_NEXT_EQE_ADDR_OFFSET(pfid, 0), |
| 4162 | cp->kcq1.dma.pg_map_arr[0] & 0xffffffff); | 4859 | cp->kcq1.dma.pg_map_arr[0] & 0xffffffff); |
| 4163 | CNIC_WR(dev, BAR_CSTRORM_INTMEM + | 4860 | CNIC_WR(dev, BAR_CSTRORM_INTMEM + |
| 4164 | CSTORM_ISCSI_EQ_NEXT_EQE_ADDR_OFFSET(func, 0) + 4, | 4861 | CSTORM_ISCSI_EQ_NEXT_EQE_ADDR_OFFSET(pfid, 0) + 4, |
| 4165 | (u64) cp->kcq1.dma.pg_map_arr[0] >> 32); | 4862 | (u64) cp->kcq1.dma.pg_map_arr[0] >> 32); |
| 4166 | CNIC_WR8(dev, BAR_CSTRORM_INTMEM + | 4863 | CNIC_WR8(dev, BAR_CSTRORM_INTMEM + |
| 4167 | CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_VALID_OFFSET(func, 0), 1); | 4864 | CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_VALID_OFFSET(pfid, 0), 1); |
| 4168 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + | 4865 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + |
| 4169 | CSTORM_ISCSI_EQ_SB_NUM_OFFSET(func, 0), cp->status_blk_num); | 4866 | CSTORM_ISCSI_EQ_SB_NUM_OFFSET(pfid, 0), cp->status_blk_num); |
| 4170 | CNIC_WR8(dev, BAR_CSTRORM_INTMEM + | 4867 | CNIC_WR8(dev, BAR_CSTRORM_INTMEM + |
| 4171 | CSTORM_ISCSI_EQ_SB_INDEX_OFFSET(func, 0), | 4868 | CSTORM_ISCSI_EQ_SB_INDEX_OFFSET(pfid, 0), |
| 4172 | HC_INDEX_C_ISCSI_EQ_CONS); | 4869 | HC_INDEX_ISCSI_EQ_CONS); |
| 4173 | 4870 | ||
| 4174 | for (i = 0; i < cp->conn_buf_info.num_pages; i++) { | 4871 | for (i = 0; i < cp->conn_buf_info.num_pages; i++) { |
| 4175 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + | 4872 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + |
| 4176 | TSTORM_ISCSI_CONN_BUF_PBL_OFFSET(func, i), | 4873 | TSTORM_ISCSI_CONN_BUF_PBL_OFFSET(pfid, i), |
| 4177 | cp->conn_buf_info.pgtbl[2 * i]); | 4874 | cp->conn_buf_info.pgtbl[2 * i]); |
| 4178 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + | 4875 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + |
| 4179 | TSTORM_ISCSI_CONN_BUF_PBL_OFFSET(func, i) + 4, | 4876 | TSTORM_ISCSI_CONN_BUF_PBL_OFFSET(pfid, i) + 4, |
| 4180 | cp->conn_buf_info.pgtbl[(2 * i) + 1]); | 4877 | cp->conn_buf_info.pgtbl[(2 * i) + 1]); |
| 4181 | } | 4878 | } |
| 4182 | 4879 | ||
| 4183 | CNIC_WR(dev, BAR_USTRORM_INTMEM + | 4880 | CNIC_WR(dev, BAR_USTRORM_INTMEM + |
| 4184 | USTORM_ISCSI_GLOBAL_BUF_PHYS_ADDR_OFFSET(func), | 4881 | USTORM_ISCSI_GLOBAL_BUF_PHYS_ADDR_OFFSET(pfid), |
| 4185 | cp->gbl_buf_info.pg_map_arr[0] & 0xffffffff); | 4882 | cp->gbl_buf_info.pg_map_arr[0] & 0xffffffff); |
| 4186 | CNIC_WR(dev, BAR_USTRORM_INTMEM + | 4883 | CNIC_WR(dev, BAR_USTRORM_INTMEM + |
| 4187 | USTORM_ISCSI_GLOBAL_BUF_PHYS_ADDR_OFFSET(func) + 4, | 4884 | USTORM_ISCSI_GLOBAL_BUF_PHYS_ADDR_OFFSET(pfid) + 4, |
| 4188 | (u64) cp->gbl_buf_info.pg_map_arr[0] >> 32); | 4885 | (u64) cp->gbl_buf_info.pg_map_arr[0] >> 32); |
| 4189 | 4886 | ||
| 4887 | CNIC_WR(dev, BAR_TSTRORM_INTMEM + | ||
| 4888 | TSTORM_ISCSI_TCP_LOCAL_ADV_WND_OFFSET(pfid), DEF_RCV_BUF); | ||
| 4889 | |||
| 4190 | cnic_setup_bnx2x_context(dev); | 4890 | cnic_setup_bnx2x_context(dev); |
| 4191 | 4891 | ||
| 4192 | eq_idx = CNIC_RD16(dev, BAR_CSTRORM_INTMEM + | ||
| 4193 | CSTORM_SB_HOST_STATUS_BLOCK_C_OFFSET(port, sb_id) + | ||
| 4194 | offsetof(struct cstorm_status_block_c, | ||
| 4195 | index_values[HC_INDEX_C_ISCSI_EQ_CONS])); | ||
| 4196 | if (eq_idx != 0) { | ||
| 4197 | netdev_err(dev->netdev, "EQ cons index %x != 0\n", eq_idx); | ||
| 4198 | return -EBUSY; | ||
| 4199 | } | ||
| 4200 | ret = cnic_init_bnx2x_irq(dev); | 4892 | ret = cnic_init_bnx2x_irq(dev); |
| 4201 | if (ret) | 4893 | if (ret) |
| 4202 | return ret; | 4894 | return ret; |
| 4203 | 4895 | ||
| 4204 | cnic_init_bnx2x_tx_ring(dev); | ||
| 4205 | cnic_init_bnx2x_rx_ring(dev); | ||
| 4206 | |||
| 4207 | return 0; | 4896 | return 0; |
| 4208 | } | 4897 | } |
| 4209 | 4898 | ||
| 4210 | static void cnic_init_rings(struct cnic_dev *dev) | 4899 | static void cnic_init_rings(struct cnic_dev *dev) |
| 4211 | { | 4900 | { |
| 4901 | struct cnic_local *cp = dev->cnic_priv; | ||
| 4902 | struct cnic_uio_dev *udev = cp->udev; | ||
| 4903 | |||
| 4904 | if (test_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags)) | ||
| 4905 | return; | ||
| 4906 | |||
| 4212 | if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) { | 4907 | if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) { |
| 4213 | cnic_init_bnx2_tx_ring(dev); | 4908 | cnic_init_bnx2_tx_ring(dev); |
| 4214 | cnic_init_bnx2_rx_ring(dev); | 4909 | cnic_init_bnx2_rx_ring(dev); |
| 4910 | set_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags); | ||
| 4215 | } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { | 4911 | } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { |
| 4216 | struct cnic_local *cp = dev->cnic_priv; | 4912 | u32 cli = cp->ethdev->iscsi_l2_client_id; |
| 4217 | u32 cli = BNX2X_ISCSI_CL_ID(CNIC_E1HVN(cp)); | 4913 | u32 cid = cp->ethdev->iscsi_l2_cid; |
| 4914 | u32 cl_qzone_id; | ||
| 4915 | struct client_init_ramrod_data *data; | ||
| 4218 | union l5cm_specific_data l5_data; | 4916 | union l5cm_specific_data l5_data; |
| 4219 | struct ustorm_eth_rx_producers rx_prods = {0}; | 4917 | struct ustorm_eth_rx_producers rx_prods = {0}; |
| 4220 | u32 off, i; | 4918 | u32 off, i; |
| @@ -4223,21 +4921,33 @@ static void cnic_init_rings(struct cnic_dev *dev) | |||
| 4223 | rx_prods.cqe_prod = BNX2X_MAX_RCQ_DESC_CNT; | 4921 | rx_prods.cqe_prod = BNX2X_MAX_RCQ_DESC_CNT; |
| 4224 | barrier(); | 4922 | barrier(); |
| 4225 | 4923 | ||
| 4924 | cl_qzone_id = BNX2X_CL_QZONE_ID(cp, cli); | ||
| 4925 | |||
| 4226 | off = BAR_USTRORM_INTMEM + | 4926 | off = BAR_USTRORM_INTMEM + |
| 4227 | USTORM_RX_PRODS_OFFSET(CNIC_PORT(cp), cli); | 4927 | (BNX2X_CHIP_IS_E2(cp->chip_id) ? |
| 4928 | USTORM_RX_PRODS_E2_OFFSET(cl_qzone_id) : | ||
| 4929 | USTORM_RX_PRODS_E1X_OFFSET(CNIC_PORT(cp), cli)); | ||
| 4228 | 4930 | ||
| 4229 | for (i = 0; i < sizeof(struct ustorm_eth_rx_producers) / 4; i++) | 4931 | for (i = 0; i < sizeof(struct ustorm_eth_rx_producers) / 4; i++) |
| 4230 | CNIC_WR(dev, off + i * 4, ((u32 *) &rx_prods)[i]); | 4932 | CNIC_WR(dev, off + i * 4, ((u32 *) &rx_prods)[i]); |
| 4231 | 4933 | ||
| 4232 | set_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); | 4934 | set_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); |
| 4233 | 4935 | ||
| 4234 | cnic_init_bnx2x_tx_ring(dev); | 4936 | data = udev->l2_buf; |
| 4235 | cnic_init_bnx2x_rx_ring(dev); | 4937 | |
| 4938 | memset(data, 0, sizeof(*data)); | ||
| 4939 | |||
| 4940 | cnic_init_bnx2x_tx_ring(dev, data); | ||
| 4941 | cnic_init_bnx2x_rx_ring(dev, data); | ||
| 4942 | |||
| 4943 | l5_data.phy_address.lo = udev->l2_buf_map & 0xffffffff; | ||
| 4944 | l5_data.phy_address.hi = (u64) udev->l2_buf_map >> 32; | ||
| 4945 | |||
| 4946 | set_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags); | ||
| 4236 | 4947 | ||
| 4237 | l5_data.phy_address.lo = cli; | ||
| 4238 | l5_data.phy_address.hi = 0; | ||
| 4239 | cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_CLIENT_SETUP, | 4948 | cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_CLIENT_SETUP, |
| 4240 | BNX2X_ISCSI_L2_CID, ETH_CONNECTION_TYPE, &l5_data); | 4949 | cid, ETH_CONNECTION_TYPE, &l5_data); |
| 4950 | |||
| 4241 | i = 0; | 4951 | i = 0; |
| 4242 | while (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags) && | 4952 | while (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags) && |
| 4243 | ++i < 10) | 4953 | ++i < 10) |
| @@ -4246,29 +4956,35 @@ static void cnic_init_rings(struct cnic_dev *dev) | |||
| 4246 | if (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags)) | 4956 | if (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags)) |
| 4247 | netdev_err(dev->netdev, | 4957 | netdev_err(dev->netdev, |
| 4248 | "iSCSI CLIENT_SETUP did not complete\n"); | 4958 | "iSCSI CLIENT_SETUP did not complete\n"); |
| 4249 | cnic_kwq_completion(dev, 1); | 4959 | cnic_spq_completion(dev, DRV_CTL_RET_L2_SPQ_CREDIT_CMD, 1); |
| 4250 | cnic_ring_ctl(dev, BNX2X_ISCSI_L2_CID, cli, 1); | 4960 | cnic_ring_ctl(dev, cid, cli, 1); |
| 4251 | } | 4961 | } |
| 4252 | } | 4962 | } |
| 4253 | 4963 | ||
| 4254 | static void cnic_shutdown_rings(struct cnic_dev *dev) | 4964 | static void cnic_shutdown_rings(struct cnic_dev *dev) |
| 4255 | { | 4965 | { |
| 4966 | struct cnic_local *cp = dev->cnic_priv; | ||
| 4967 | |||
| 4968 | if (!test_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags)) | ||
| 4969 | return; | ||
| 4970 | |||
| 4256 | if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) { | 4971 | if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) { |
| 4257 | cnic_shutdown_bnx2_rx_ring(dev); | 4972 | cnic_shutdown_bnx2_rx_ring(dev); |
| 4258 | } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { | 4973 | } else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { |
| 4259 | struct cnic_local *cp = dev->cnic_priv; | 4974 | struct cnic_local *cp = dev->cnic_priv; |
| 4260 | u32 cli = BNX2X_ISCSI_CL_ID(CNIC_E1HVN(cp)); | 4975 | u32 cli = cp->ethdev->iscsi_l2_client_id; |
| 4976 | u32 cid = cp->ethdev->iscsi_l2_cid; | ||
| 4261 | union l5cm_specific_data l5_data; | 4977 | union l5cm_specific_data l5_data; |
| 4262 | int i; | 4978 | int i; |
| 4263 | 4979 | ||
| 4264 | cnic_ring_ctl(dev, BNX2X_ISCSI_L2_CID, cli, 0); | 4980 | cnic_ring_ctl(dev, cid, cli, 0); |
| 4265 | 4981 | ||
| 4266 | set_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); | 4982 | set_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags); |
| 4267 | 4983 | ||
| 4268 | l5_data.phy_address.lo = cli; | 4984 | l5_data.phy_address.lo = cli; |
| 4269 | l5_data.phy_address.hi = 0; | 4985 | l5_data.phy_address.hi = 0; |
| 4270 | cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_HALT, | 4986 | cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_HALT, |
| 4271 | BNX2X_ISCSI_L2_CID, ETH_CONNECTION_TYPE, &l5_data); | 4987 | cid, ETH_CONNECTION_TYPE, &l5_data); |
| 4272 | i = 0; | 4988 | i = 0; |
| 4273 | while (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags) && | 4989 | while (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags) && |
| 4274 | ++i < 10) | 4990 | ++i < 10) |
| @@ -4277,14 +4993,14 @@ static void cnic_shutdown_rings(struct cnic_dev *dev) | |||
| 4277 | if (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags)) | 4993 | if (test_bit(CNIC_LCL_FL_L2_WAIT, &cp->cnic_local_flags)) |
| 4278 | netdev_err(dev->netdev, | 4994 | netdev_err(dev->netdev, |
| 4279 | "iSCSI CLIENT_HALT did not complete\n"); | 4995 | "iSCSI CLIENT_HALT did not complete\n"); |
| 4280 | cnic_kwq_completion(dev, 1); | 4996 | cnic_spq_completion(dev, DRV_CTL_RET_L2_SPQ_CREDIT_CMD, 1); |
| 4281 | 4997 | ||
| 4282 | memset(&l5_data, 0, sizeof(l5_data)); | 4998 | memset(&l5_data, 0, sizeof(l5_data)); |
| 4283 | cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_ETH_CFC_DEL, | 4999 | cnic_submit_kwqe_16(dev, RAMROD_CMD_ID_COMMON_CFC_DEL, |
| 4284 | BNX2X_ISCSI_L2_CID, ETH_CONNECTION_TYPE | | 5000 | cid, NONE_CONNECTION_TYPE, &l5_data); |
| 4285 | (1 << SPE_HDR_COMMON_RAMROD_SHIFT), &l5_data); | ||
| 4286 | msleep(10); | 5001 | msleep(10); |
| 4287 | } | 5002 | } |
| 5003 | clear_bit(CNIC_LCL_FL_RINGS_INITED, &cp->cnic_local_flags); | ||
| 4288 | } | 5004 | } |
| 4289 | 5005 | ||
| 4290 | static int cnic_register_netdev(struct cnic_dev *dev) | 5006 | static int cnic_register_netdev(struct cnic_dev *dev) |
| @@ -4327,7 +5043,6 @@ static int cnic_start_hw(struct cnic_dev *dev) | |||
| 4327 | return -EALREADY; | 5043 | return -EALREADY; |
| 4328 | 5044 | ||
| 4329 | dev->regview = ethdev->io_base; | 5045 | dev->regview = ethdev->io_base; |
| 4330 | cp->chip_id = ethdev->chip_id; | ||
| 4331 | pci_dev_get(dev->pcidev); | 5046 | pci_dev_get(dev->pcidev); |
| 4332 | cp->func = PCI_FUNC(dev->pcidev->devfn); | 5047 | cp->func = PCI_FUNC(dev->pcidev->devfn); |
| 4333 | cp->status_blk.gen = ethdev->irq_arr[0].status_blk; | 5048 | cp->status_blk.gen = ethdev->irq_arr[0].status_blk; |
| @@ -4379,17 +5094,11 @@ static void cnic_stop_bnx2_hw(struct cnic_dev *dev) | |||
| 4379 | static void cnic_stop_bnx2x_hw(struct cnic_dev *dev) | 5094 | static void cnic_stop_bnx2x_hw(struct cnic_dev *dev) |
| 4380 | { | 5095 | { |
| 4381 | struct cnic_local *cp = dev->cnic_priv; | 5096 | struct cnic_local *cp = dev->cnic_priv; |
| 4382 | u8 sb_id = cp->status_blk_num; | ||
| 4383 | int port = CNIC_PORT(cp); | ||
| 4384 | 5097 | ||
| 4385 | cnic_free_irq(dev); | 5098 | cnic_free_irq(dev); |
| 4386 | CNIC_WR16(dev, BAR_CSTRORM_INTMEM + | 5099 | *cp->kcq1.hw_prod_idx_ptr = 0; |
| 4387 | CSTORM_SB_HOST_STATUS_BLOCK_C_OFFSET(port, sb_id) + | ||
| 4388 | offsetof(struct cstorm_status_block_c, | ||
| 4389 | index_values[HC_INDEX_C_ISCSI_EQ_CONS]), | ||
| 4390 | 0); | ||
| 4391 | CNIC_WR(dev, BAR_CSTRORM_INTMEM + | 5100 | CNIC_WR(dev, BAR_CSTRORM_INTMEM + |
| 4392 | CSTORM_ISCSI_EQ_CONS_OFFSET(cp->func, 0), 0); | 5101 | CSTORM_ISCSI_EQ_CONS_OFFSET(cp->pfid, 0), 0); |
| 4393 | CNIC_WR16(dev, cp->kcq1.io_addr, 0); | 5102 | CNIC_WR16(dev, cp->kcq1.io_addr, 0); |
| 4394 | cnic_free_resc(dev); | 5103 | cnic_free_resc(dev); |
| 4395 | } | 5104 | } |
| @@ -4403,10 +5112,11 @@ static void cnic_stop_hw(struct cnic_dev *dev) | |||
| 4403 | /* Need to wait for the ring shutdown event to complete | 5112 | /* Need to wait for the ring shutdown event to complete |
| 4404 | * before clearing the CNIC_UP flag. | 5113 | * before clearing the CNIC_UP flag. |
| 4405 | */ | 5114 | */ |
| 4406 | while (cp->uio_dev != -1 && i < 15) { | 5115 | while (cp->udev->uio_dev != -1 && i < 15) { |
| 4407 | msleep(100); | 5116 | msleep(100); |
| 4408 | i++; | 5117 | i++; |
| 4409 | } | 5118 | } |
| 5119 | cnic_shutdown_rings(dev); | ||
| 4410 | clear_bit(CNIC_F_CNIC_UP, &dev->flags); | 5120 | clear_bit(CNIC_F_CNIC_UP, &dev->flags); |
| 4411 | rcu_assign_pointer(cp->ulp_ops[CNIC_ULP_L4], NULL); | 5121 | rcu_assign_pointer(cp->ulp_ops[CNIC_ULP_L4], NULL); |
| 4412 | synchronize_rcu(); | 5122 | synchronize_rcu(); |
| @@ -4455,7 +5165,6 @@ static struct cnic_dev *cnic_alloc_dev(struct net_device *dev, | |||
| 4455 | 5165 | ||
| 4456 | cp = cdev->cnic_priv; | 5166 | cp = cdev->cnic_priv; |
| 4457 | cp->dev = cdev; | 5167 | cp->dev = cdev; |
| 4458 | cp->uio_dev = -1; | ||
| 4459 | cp->l2_single_buf_size = 0x400; | 5168 | cp->l2_single_buf_size = 0x400; |
| 4460 | cp->l2_rx_ring_size = 3; | 5169 | cp->l2_rx_ring_size = 3; |
| 4461 | 5170 | ||
| @@ -4488,15 +5197,11 @@ static struct cnic_dev *init_bnx2_cnic(struct net_device *dev) | |||
| 4488 | 5197 | ||
| 4489 | dev_hold(dev); | 5198 | dev_hold(dev); |
| 4490 | pci_dev_get(pdev); | 5199 | pci_dev_get(pdev); |
| 4491 | if (pdev->device == PCI_DEVICE_ID_NX2_5709 || | 5200 | if ((pdev->device == PCI_DEVICE_ID_NX2_5709 || |
| 4492 | pdev->device == PCI_DEVICE_ID_NX2_5709S) { | 5201 | pdev->device == PCI_DEVICE_ID_NX2_5709S) && |
| 4493 | u8 rev; | 5202 | (pdev->revision < 0x10)) { |
| 4494 | 5203 | pci_dev_put(pdev); | |
| 4495 | pci_read_config_byte(pdev, PCI_REVISION_ID, &rev); | 5204 | goto cnic_err; |
| 4496 | if (rev < 0x10) { | ||
| 4497 | pci_dev_put(pdev); | ||
| 4498 | goto cnic_err; | ||
| 4499 | } | ||
| 4500 | } | 5205 | } |
| 4501 | pci_dev_put(pdev); | 5206 | pci_dev_put(pdev); |
| 4502 | 5207 | ||
| @@ -4510,6 +5215,7 @@ static struct cnic_dev *init_bnx2_cnic(struct net_device *dev) | |||
| 4510 | cp = cdev->cnic_priv; | 5215 | cp = cdev->cnic_priv; |
| 4511 | cp->ethdev = ethdev; | 5216 | cp->ethdev = ethdev; |
| 4512 | cdev->pcidev = pdev; | 5217 | cdev->pcidev = pdev; |
| 5218 | cp->chip_id = ethdev->chip_id; | ||
| 4513 | 5219 | ||
| 4514 | cp->cnic_ops = &cnic_bnx2_ops; | 5220 | cp->cnic_ops = &cnic_bnx2_ops; |
| 4515 | cp->start_hw = cnic_start_bnx2_hw; | 5221 | cp->start_hw = cnic_start_bnx2_hw; |
| @@ -4564,6 +5270,15 @@ static struct cnic_dev *init_bnx2x_cnic(struct net_device *dev) | |||
| 4564 | cp = cdev->cnic_priv; | 5270 | cp = cdev->cnic_priv; |
| 4565 | cp->ethdev = ethdev; | 5271 | cp->ethdev = ethdev; |
| 4566 | cdev->pcidev = pdev; | 5272 | cdev->pcidev = pdev; |
| 5273 | cp->chip_id = ethdev->chip_id; | ||
| 5274 | |||
| 5275 | if (!(ethdev->drv_state & CNIC_DRV_STATE_NO_ISCSI)) | ||
| 5276 | cdev->max_iscsi_conn = ethdev->max_iscsi_conn; | ||
| 5277 | if (BNX2X_CHIP_IS_E2(cp->chip_id) && | ||
| 5278 | !(ethdev->drv_state & CNIC_DRV_STATE_NO_FCOE)) | ||
| 5279 | cdev->max_fcoe_conn = ethdev->max_fcoe_conn; | ||
| 5280 | |||
| 5281 | memcpy(cdev->mac_addr, ethdev->iscsi_mac, 6); | ||
| 4567 | 5282 | ||
| 4568 | cp->cnic_ops = &cnic_bnx2x_ops; | 5283 | cp->cnic_ops = &cnic_bnx2x_ops; |
| 4569 | cp->start_hw = cnic_start_bnx2x_hw; | 5284 | cp->start_hw = cnic_start_bnx2x_hw; |
| @@ -4575,7 +5290,10 @@ static struct cnic_dev *init_bnx2x_cnic(struct net_device *dev) | |||
| 4575 | cp->stop_cm = cnic_cm_stop_bnx2x_hw; | 5290 | cp->stop_cm = cnic_cm_stop_bnx2x_hw; |
| 4576 | cp->enable_int = cnic_enable_bnx2x_int; | 5291 | cp->enable_int = cnic_enable_bnx2x_int; |
| 4577 | cp->disable_int_sync = cnic_disable_bnx2x_int_sync; | 5292 | cp->disable_int_sync = cnic_disable_bnx2x_int_sync; |
| 4578 | cp->ack_int = cnic_ack_bnx2x_msix; | 5293 | if (BNX2X_CHIP_IS_E2(cp->chip_id)) |
| 5294 | cp->ack_int = cnic_ack_bnx2x_e2_msix; | ||
| 5295 | else | ||
| 5296 | cp->ack_int = cnic_ack_bnx2x_msix; | ||
| 4579 | cp->close_conn = cnic_close_bnx2x_conn; | 5297 | cp->close_conn = cnic_close_bnx2x_conn; |
| 4580 | cp->next_idx = cnic_bnx2x_next_idx; | 5298 | cp->next_idx = cnic_bnx2x_next_idx; |
| 4581 | cp->hw_idx = cnic_bnx2x_hw_idx; | 5299 | cp->hw_idx = cnic_bnx2x_hw_idx; |
| @@ -4683,6 +5401,7 @@ static struct notifier_block cnic_netdev_notifier = { | |||
| 4683 | static void cnic_release(void) | 5401 | static void cnic_release(void) |
| 4684 | { | 5402 | { |
| 4685 | struct cnic_dev *dev; | 5403 | struct cnic_dev *dev; |
| 5404 | struct cnic_uio_dev *udev; | ||
| 4686 | 5405 | ||
| 4687 | while (!list_empty(&cnic_dev_list)) { | 5406 | while (!list_empty(&cnic_dev_list)) { |
| 4688 | dev = list_entry(cnic_dev_list.next, struct cnic_dev, list); | 5407 | dev = list_entry(cnic_dev_list.next, struct cnic_dev, list); |
| @@ -4696,6 +5415,11 @@ static void cnic_release(void) | |||
| 4696 | list_del_init(&dev->list); | 5415 | list_del_init(&dev->list); |
| 4697 | cnic_free_dev(dev); | 5416 | cnic_free_dev(dev); |
| 4698 | } | 5417 | } |
| 5418 | while (!list_empty(&cnic_udev_list)) { | ||
| 5419 | udev = list_entry(cnic_udev_list.next, struct cnic_uio_dev, | ||
| 5420 | list); | ||
| 5421 | cnic_free_uio(udev); | ||
| 5422 | } | ||
| 4699 | } | 5423 | } |
| 4700 | 5424 | ||
| 4701 | static int __init cnic_init(void) | 5425 | static int __init cnic_init(void) |
| @@ -4710,6 +5434,13 @@ static int __init cnic_init(void) | |||
| 4710 | return rc; | 5434 | return rc; |
| 4711 | } | 5435 | } |
| 4712 | 5436 | ||
| 5437 | cnic_wq = create_singlethread_workqueue("cnic_wq"); | ||
| 5438 | if (!cnic_wq) { | ||
| 5439 | cnic_release(); | ||
| 5440 | unregister_netdevice_notifier(&cnic_netdev_notifier); | ||
| 5441 | return -ENOMEM; | ||
| 5442 | } | ||
| 5443 | |||
| 4713 | return 0; | 5444 | return 0; |
| 4714 | } | 5445 | } |
| 4715 | 5446 | ||
| @@ -4717,6 +5448,7 @@ static void __exit cnic_exit(void) | |||
| 4717 | { | 5448 | { |
| 4718 | unregister_netdevice_notifier(&cnic_netdev_notifier); | 5449 | unregister_netdevice_notifier(&cnic_netdev_notifier); |
| 4719 | cnic_release(); | 5450 | cnic_release(); |
| 5451 | destroy_workqueue(cnic_wq); | ||
| 4720 | } | 5452 | } |
| 4721 | 5453 | ||
| 4722 | module_init(cnic_init); | 5454 | module_init(cnic_init); |
