aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/benet
diff options
context:
space:
mode:
authorSathya Perla <sathyap@serverengines.com>2009-06-17 20:09:25 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-19 03:18:41 -0400
commit24307eef74bd38e3fc6a6df8f8a1bfc48967f9f6 (patch)
tree86583877a2178f8ea1baff35e2262a6b1de8bd58 /drivers/net/benet
parent6ac7b687cb3acc437a586794949a43f5249956bb (diff)
be2net: cleanup multicast_set cmd to avoid mc_list copy
Cleanup multicast_set method to avoid an extra copy of mc_list and unwanted promiscuos sets to BE. Signed-off-by: Sathya Perla <sathyap@serverengines.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/benet')
-rw-r--r--drivers/net/benet/be.h1
-rw-r--r--drivers/net/benet/be_cmds.c19
-rw-r--r--drivers/net/benet/be_cmds.h4
-rw-r--r--drivers/net/benet/be_main.c49
4 files changed, 32 insertions, 41 deletions
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h
index ef5be133ce68..94b75cb072f7 100644
--- a/drivers/net/benet/be.h
+++ b/drivers/net/benet/be.h
@@ -274,6 +274,7 @@ struct be_adapter {
274 274
275 struct be_link_info link; 275 struct be_link_info link;
276 u32 port_num; 276 u32 port_num;
277 bool promiscuous;
277}; 278};
278 279
279extern struct ethtool_ops be_ethtool_ops; 280extern struct ethtool_ops be_ethtool_ops;
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index e4ad5e67fde7..4a2e1f518f78 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -927,8 +927,8 @@ int be_cmd_promiscuous_config(struct be_ctrl_info *ctrl, u8 port_num, bool en)
927 * Use MCC for this command as it may be called in BH context 927 * Use MCC for this command as it may be called in BH context
928 * (mc == NULL) => multicast promiscous 928 * (mc == NULL) => multicast promiscous
929 */ 929 */
930int be_cmd_mcast_mac_set(struct be_ctrl_info *ctrl, u32 if_id, u8 *mac_table, 930int be_cmd_multicast_set(struct be_ctrl_info *ctrl, u32 if_id,
931 u32 num, bool promiscuous) 931 struct dev_mc_list *mc_list, u32 mc_count)
932{ 932{
933#define BE_MAX_MC 32 /* set mcast promisc if > 32 */ 933#define BE_MAX_MC 32 /* set mcast promisc if > 32 */
934 struct be_mcc_wrb *wrb; 934 struct be_mcc_wrb *wrb;
@@ -947,11 +947,16 @@ int be_cmd_mcast_mac_set(struct be_ctrl_info *ctrl, u32 if_id, u8 *mac_table,
947 OPCODE_COMMON_NTWK_MULTICAST_SET, sizeof(*req)); 947 OPCODE_COMMON_NTWK_MULTICAST_SET, sizeof(*req));
948 948
949 req->interface_id = if_id; 949 req->interface_id = if_id;
950 req->promiscuous = promiscuous; 950 if (mc_list && mc_count <= BE_MAX_MC) {
951 if (!promiscuous) { 951 int i;
952 req->num_mac = cpu_to_le16(num); 952 struct dev_mc_list *mc;
953 if (num) 953
954 memcpy(req->mac, mac_table, ETH_ALEN * num); 954 req->num_mac = cpu_to_le16(mc_count);
955
956 for (mc = mc_list, i = 0; mc; mc = mc->next, i++)
957 memcpy(req->mac[i].byte, mc->dmi_addr, ETH_ALEN);
958 } else {
959 req->promiscuous = 1;
955 } 960 }
956 961
957 be_mcc_notify_wait(ctrl); 962 be_mcc_notify_wait(ctrl);
diff --git a/drivers/net/benet/be_cmds.h b/drivers/net/benet/be_cmds.h
index 0a9189defc2a..a567aa437ec9 100644
--- a/drivers/net/benet/be_cmds.h
+++ b/drivers/net/benet/be_cmds.h
@@ -716,8 +716,8 @@ extern int be_cmd_vlan_config(struct be_ctrl_info *ctrl, u32 if_id,
716 bool promiscuous); 716 bool promiscuous);
717extern int be_cmd_promiscuous_config(struct be_ctrl_info *ctrl, 717extern int be_cmd_promiscuous_config(struct be_ctrl_info *ctrl,
718 u8 port_num, bool en); 718 u8 port_num, bool en);
719extern int be_cmd_mcast_mac_set(struct be_ctrl_info *ctrl, u32 if_id, 719extern int be_cmd_multicast_set(struct be_ctrl_info *ctrl, u32 if_id,
720 u8 *mac_table, u32 num, bool promiscuous); 720 struct dev_mc_list *mc_list, u32 mc_count);
721extern int be_cmd_set_flow_control(struct be_ctrl_info *ctrl, 721extern int be_cmd_set_flow_control(struct be_ctrl_info *ctrl,
722 u32 tx_fc, u32 rx_fc); 722 u32 tx_fc, u32 rx_fc);
723extern int be_cmd_get_flow_control(struct be_ctrl_info *ctrl, 723extern int be_cmd_get_flow_control(struct be_ctrl_info *ctrl,
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index a4ce80e776b6..3dc68034c21d 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -549,47 +549,32 @@ static void be_vlan_rem_vid(struct net_device *netdev, u16 vid)
549 be_vid_config(netdev); 549 be_vid_config(netdev);
550} 550}
551 551
552static void be_set_multicast_filter(struct net_device *netdev) 552static void be_set_multicast_list(struct net_device *netdev)
553{ 553{
554 struct be_adapter *adapter = netdev_priv(netdev); 554 struct be_adapter *adapter = netdev_priv(netdev);
555 struct dev_mc_list *mc_ptr; 555 struct be_ctrl_info *ctrl = &adapter->ctrl;
556 u8 mac_addr[32][ETH_ALEN];
557 int i = 0;
558 556
559 if (netdev->flags & IFF_ALLMULTI) { 557 if (netdev->flags & IFF_PROMISC) {
560 /* set BE in Multicast promiscuous */ 558 be_cmd_promiscuous_config(ctrl, adapter->port_num, 1);
561 be_cmd_mcast_mac_set(&adapter->ctrl, 559 adapter->promiscuous = true;
562 adapter->if_handle, NULL, 0, true); 560 goto done;
563 return;
564 } 561 }
565 562
566 for (mc_ptr = netdev->mc_list; mc_ptr; mc_ptr = mc_ptr->next) { 563 /* BE was previously in promiscous mode; disable it */
567 memcpy(&mac_addr[i][0], mc_ptr->dmi_addr, ETH_ALEN); 564 if (adapter->promiscuous) {
568 if (++i >= 32) { 565 adapter->promiscuous = false;
569 be_cmd_mcast_mac_set(&adapter->ctrl, 566 be_cmd_promiscuous_config(ctrl, adapter->port_num, 0);
570 adapter->if_handle, &mac_addr[0][0], i, false);
571 i = 0;
572 }
573
574 } 567 }
575 568
576 if (i) { 569 if (netdev->flags & IFF_ALLMULTI) {
577 /* reset the promiscuous mode also. */ 570 be_cmd_multicast_set(ctrl, adapter->if_handle, NULL, 0);
578 be_cmd_mcast_mac_set(&adapter->ctrl, 571 goto done;
579 adapter->if_handle, &mac_addr[0][0], i, false);
580 } 572 }
581}
582
583static void be_set_multicast_list(struct net_device *netdev)
584{
585 struct be_adapter *adapter = netdev_priv(netdev);
586 573
587 if (netdev->flags & IFF_PROMISC) { 574 be_cmd_multicast_set(ctrl, adapter->if_handle, netdev->mc_list,
588 be_cmd_promiscuous_config(&adapter->ctrl, adapter->port_num, 1); 575 netdev->mc_count);
589 } else { 576done:
590 be_cmd_promiscuous_config(&adapter->ctrl, adapter->port_num, 0); 577 return;
591 be_set_multicast_filter(netdev);
592 }
593} 578}
594 579
595static void be_rx_rate_update(struct be_adapter *adapter) 580static void be_rx_rate_update(struct be_adapter *adapter)