aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Kravkov <dmitry@broadcom.com>2011-11-28 07:31:49 -0500
committerDavid S. Miller <davem@davemloft.net>2011-11-29 19:02:57 -0500
commit614c76df1d1224dc2eee8678fab6e0b95b49b7da (patch)
treefc69e019e8d5c833ddfe1188ea94fc774707411d
parent7e02e5433e004713a89f5f865a243133b55dcc88 (diff)
bnx2x: handle iSCSI SD mode
in iSCSI SD mode to bnx2x device assigned single mac address which is supposted to be iscsi mac. If this mode is recognized bnx2x will disable LRO, decrease number of queues to 1 and rx ring size to the minumum allowed by FW, this in order minimize memory use. It will tranfer mac for iscsi usage and zero primary mac of the netdev. Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Reviewed-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x.h12
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c21
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h12
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c50
4 files changed, 86 insertions, 9 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 0f7b7a463eba..6c7bd638d6ed 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -2084,4 +2084,16 @@ static const u32 dmae_reg_go_c[] = {
2084 2084
2085void bnx2x_set_ethtool_ops(struct net_device *netdev); 2085void bnx2x_set_ethtool_ops(struct net_device *netdev);
2086void bnx2x_notify_link_changed(struct bnx2x *bp); 2086void bnx2x_notify_link_changed(struct bnx2x *bp);
2087
2088
2089#define BNX2X_MF_PROTOCOL(bp) \
2090 ((bp)->mf_config[BP_VN(bp)] & FUNC_MF_CFG_PROTOCOL_MASK)
2091
2092#ifdef BCM_CNIC
2093#define BNX2X_IS_MF_PROTOCOL_ISCSI(bp) \
2094 (BNX2X_MF_PROTOCOL(bp) == FUNC_MF_CFG_PROTOCOL_ISCSI)
2095
2096#define IS_MF_ISCSI_SD(bp) (IS_MF_SD(bp) && BNX2X_IS_MF_PROTOCOL_ISCSI(bp))
2097#endif
2098
2087#endif /* bnx2x.h */ 2099#endif /* bnx2x.h */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 42ce56617042..79695bb034d6 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -1441,6 +1441,11 @@ void bnx2x_set_num_queues(struct bnx2x *bp)
1441 break; 1441 break;
1442 } 1442 }
1443 1443
1444#ifdef BCM_CNIC
1445 /* override in ISCSI SD mod */
1446 if (IS_MF_ISCSI_SD(bp))
1447 bp->num_queues = 1;
1448#endif
1444 /* Add special queues */ 1449 /* Add special queues */
1445 bp->num_queues += NON_ETH_CONTEXT_USE; 1450 bp->num_queues += NON_ETH_CONTEXT_USE;
1446} 1451}
@@ -2988,8 +2993,13 @@ int bnx2x_change_mac_addr(struct net_device *dev, void *p)
2988 struct bnx2x *bp = netdev_priv(dev); 2993 struct bnx2x *bp = netdev_priv(dev);
2989 int rc = 0; 2994 int rc = 0;
2990 2995
2991 if (!is_valid_ether_addr((u8 *)(addr->sa_data))) 2996 if (!bnx2x_is_valid_ether_addr(bp, addr->sa_data))
2997 return -EINVAL;
2998
2999#ifdef BCM_CNIC
3000 if (IS_MF_ISCSI_SD(bp) && !is_zero_ether_addr(addr->sa_data))
2992 return -EINVAL; 3001 return -EINVAL;
3002#endif
2993 3003
2994 if (netif_running(dev)) { 3004 if (netif_running(dev)) {
2995 rc = bnx2x_set_eth_mac(bp, false); 3005 rc = bnx2x_set_eth_mac(bp, false);
@@ -3105,7 +3115,12 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)
3105 u8 cos; 3115 u8 cos;
3106 int rx_ring_size = 0; 3116 int rx_ring_size = 0;
3107 3117
3108 /* if rx_ring_size specified - use it */ 3118#ifdef BCM_CNIC
3119 if (IS_MF_ISCSI_SD(bp)) {
3120 rx_ring_size = MIN_RX_SIZE_NONTPA;
3121 bp->rx_ring_size = rx_ring_size;
3122 } else
3123#endif
3109 if (!bp->rx_ring_size) { 3124 if (!bp->rx_ring_size) {
3110 3125
3111 rx_ring_size = MAX_RX_AVAIL/BNX2X_NUM_RX_QUEUES(bp); 3126 rx_ring_size = MAX_RX_AVAIL/BNX2X_NUM_RX_QUEUES(bp);
@@ -3115,7 +3130,7 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)
3115 MIN_RX_SIZE_TPA, rx_ring_size); 3130 MIN_RX_SIZE_TPA, rx_ring_size);
3116 3131
3117 bp->rx_ring_size = rx_ring_size; 3132 bp->rx_ring_size = rx_ring_size;
3118 } else 3133 } else /* if rx_ring_size specified - use it */
3119 rx_ring_size = bp->rx_ring_size; 3134 rx_ring_size = bp->rx_ring_size;
3120 3135
3121 /* Common */ 3136 /* Common */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index 80c5ed08e419..2891cdcabdc8 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -20,6 +20,7 @@
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/netdevice.h> 22#include <linux/netdevice.h>
23#include <linux/etherdevice.h>
23 24
24 25
25#include "bnx2x.h" 26#include "bnx2x.h"
@@ -1554,4 +1555,15 @@ static inline void bnx2x_update_drv_flags(struct bnx2x *bp, u32 flags, u32 set)
1554 } 1555 }
1555} 1556}
1556 1557
1558static inline bool bnx2x_is_valid_ether_addr(struct bnx2x *bp, u8 *addr)
1559{
1560 if (is_valid_ether_addr(addr))
1561 return true;
1562#ifdef BCM_CNIC
1563 if (is_zero_ether_addr(addr) && IS_MF_ISCSI_SD(bp))
1564 return true;
1565#endif
1566 return false;
1567}
1568
1557#endif /* BNX2X_CMN_H */ 1569#endif /* BNX2X_CMN_H */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 0cdbb70ef83e..2213e0be5e63 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -7017,6 +7017,13 @@ int bnx2x_set_eth_mac(struct bnx2x *bp, bool set)
7017{ 7017{
7018 unsigned long ramrod_flags = 0; 7018 unsigned long ramrod_flags = 0;
7019 7019
7020#ifdef BCM_CNIC
7021 if (is_zero_ether_addr(bp->dev->dev_addr) && IS_MF_ISCSI_SD(bp)) {
7022 DP(NETIF_MSG_IFUP, "Ignoring Zero MAC for iSCSI SD mode\n");
7023 return 0;
7024 }
7025#endif
7026
7020 DP(NETIF_MSG_IFUP, "Adding Eth MAC\n"); 7027 DP(NETIF_MSG_IFUP, "Adding Eth MAC\n");
7021 7028
7022 __set_bit(RAMROD_COMP_WAIT, &ramrod_flags); 7029 __set_bit(RAMROD_COMP_WAIT, &ramrod_flags);
@@ -9400,7 +9407,8 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
9400 bnx2x_set_mac_buf(bp->dev->dev_addr, val, val2); 9407 bnx2x_set_mac_buf(bp->dev->dev_addr, val, val2);
9401 9408
9402#ifdef BCM_CNIC 9409#ifdef BCM_CNIC
9403 /* iSCSI and FCoE NPAR MACs: if there is no either iSCSI or 9410 /*
9411 * iSCSI and FCoE NPAR MACs: if there is no either iSCSI or
9404 * FCoE MAC then the appropriate feature should be disabled. 9412 * FCoE MAC then the appropriate feature should be disabled.
9405 */ 9413 */
9406 if (IS_MF_SI(bp)) { 9414 if (IS_MF_SI(bp)) {
@@ -9422,11 +9430,22 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
9422 val = MF_CFG_RD(bp, func_ext_config[func]. 9430 val = MF_CFG_RD(bp, func_ext_config[func].
9423 fcoe_mac_addr_lower); 9431 fcoe_mac_addr_lower);
9424 bnx2x_set_mac_buf(fip_mac, val, val2); 9432 bnx2x_set_mac_buf(fip_mac, val, val2);
9425 BNX2X_DEV_INFO("Read FCoE L2 MAC to %pM\n", 9433 BNX2X_DEV_INFO("Read FCoE L2 MAC: %pM\n",
9426 fip_mac); 9434 fip_mac);
9427 9435
9428 } else 9436 } else
9429 bp->flags |= NO_FCOE_FLAG; 9437 bp->flags |= NO_FCOE_FLAG;
9438 } else { /* SD mode */
9439 if (BNX2X_IS_MF_PROTOCOL_ISCSI(bp)) {
9440 /* use primary mac as iscsi mac */
9441 memcpy(iscsi_mac, bp->dev->dev_addr, ETH_ALEN);
9442 /* Zero primary MAC configuration */
9443 memset(bp->dev->dev_addr, 0, ETH_ALEN);
9444
9445 BNX2X_DEV_INFO("SD ISCSI MODE\n");
9446 BNX2X_DEV_INFO("Read iSCSI MAC: %pM\n",
9447 iscsi_mac);
9448 }
9430 } 9449 }
9431#endif 9450#endif
9432 } else { 9451 } else {
@@ -9475,7 +9494,7 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
9475 } 9494 }
9476#endif 9495#endif
9477 9496
9478 if (!is_valid_ether_addr(bp->dev->dev_addr)) 9497 if (!bnx2x_is_valid_ether_addr(bp, bp->dev->dev_addr))
9479 dev_err(&bp->pdev->dev, 9498 dev_err(&bp->pdev->dev,
9480 "bad Ethernet MAC address configuration: " 9499 "bad Ethernet MAC address configuration: "
9481 "%pM, change it manually before bringing up " 9500 "%pM, change it manually before bringing up "
@@ -9866,15 +9885,20 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
9866 9885
9867 bp->multi_mode = multi_mode; 9886 bp->multi_mode = multi_mode;
9868 9887
9888 bp->disable_tpa = disable_tpa;
9889
9890#ifdef BCM_CNIC
9891 bp->disable_tpa |= IS_MF_ISCSI_SD(bp);
9892#endif
9893
9869 /* Set TPA flags */ 9894 /* Set TPA flags */
9870 if (disable_tpa) { 9895 if (bp->disable_tpa) {
9871 bp->flags &= ~TPA_ENABLE_FLAG; 9896 bp->flags &= ~TPA_ENABLE_FLAG;
9872 bp->dev->features &= ~NETIF_F_LRO; 9897 bp->dev->features &= ~NETIF_F_LRO;
9873 } else { 9898 } else {
9874 bp->flags |= TPA_ENABLE_FLAG; 9899 bp->flags |= TPA_ENABLE_FLAG;
9875 bp->dev->features |= NETIF_F_LRO; 9900 bp->dev->features |= NETIF_F_LRO;
9876 } 9901 }
9877 bp->disable_tpa = disable_tpa;
9878 9902
9879 if (CHIP_IS_E1(bp)) 9903 if (CHIP_IS_E1(bp))
9880 bp->dropless_fc = 0; 9904 bp->dropless_fc = 0;
@@ -10145,6 +10169,11 @@ void bnx2x_set_rx_mode(struct net_device *dev)
10145 } 10169 }
10146 10170
10147 bp->rx_mode = rx_mode; 10171 bp->rx_mode = rx_mode;
10172#ifdef BCM_CNIC
10173 /* handle ISCSI SD mode */
10174 if (IS_MF_ISCSI_SD(bp))
10175 bp->rx_mode = BNX2X_RX_MODE_NONE;
10176#endif
10148 10177
10149 /* Schedule the rx_mode command */ 10178 /* Schedule the rx_mode command */
10150 if (test_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state)) { 10179 if (test_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state)) {
@@ -10224,6 +10253,15 @@ static void poll_bnx2x(struct net_device *dev)
10224} 10253}
10225#endif 10254#endif
10226 10255
10256static int bnx2x_validate_addr(struct net_device *dev)
10257{
10258 struct bnx2x *bp = netdev_priv(dev);
10259
10260 if (!bnx2x_is_valid_ether_addr(bp, dev->dev_addr))
10261 return -EADDRNOTAVAIL;
10262 return 0;
10263}
10264
10227static const struct net_device_ops bnx2x_netdev_ops = { 10265static const struct net_device_ops bnx2x_netdev_ops = {
10228 .ndo_open = bnx2x_open, 10266 .ndo_open = bnx2x_open,
10229 .ndo_stop = bnx2x_close, 10267 .ndo_stop = bnx2x_close,
@@ -10231,7 +10269,7 @@ static const struct net_device_ops bnx2x_netdev_ops = {
10231 .ndo_select_queue = bnx2x_select_queue, 10269 .ndo_select_queue = bnx2x_select_queue,
10232 .ndo_set_rx_mode = bnx2x_set_rx_mode, 10270 .ndo_set_rx_mode = bnx2x_set_rx_mode,
10233 .ndo_set_mac_address = bnx2x_change_mac_addr, 10271 .ndo_set_mac_address = bnx2x_change_mac_addr,
10234 .ndo_validate_addr = eth_validate_addr, 10272 .ndo_validate_addr = bnx2x_validate_addr,
10235 .ndo_do_ioctl = bnx2x_ioctl, 10273 .ndo_do_ioctl = bnx2x_ioctl,
10236 .ndo_change_mtu = bnx2x_change_mtu, 10274 .ndo_change_mtu = bnx2x_change_mtu,
10237 .ndo_fix_features = bnx2x_fix_features, 10275 .ndo_fix_features = bnx2x_fix_features,