Skip to contentSkip to conversation

be2net: cleanup multicast_set cmd to avoid mc_list copy

PATCH New Sathya Perla 1 participant 1 message Jun 18, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/4 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.

---
 drivers/net/benet/be.h      |    1 +
 drivers/net/benet/be_cmds.c |   19 ++++++++++------
 drivers/net/benet/be_cmds.h |    4 +-
 drivers/net/benet/be_main.c |   49 +++++++++++++++----------------------------
 4 files changed, 32 insertions(+), 41 deletions(-)
drivers/net/benet/be.h +1 -0
index ef5be13..94b75cb 100644
@@ -274,6 +274,7 @@ struct be_adapter {
 
 	struct be_link_info link;
 	u32 port_num;
+	bool promiscuous;
 };
 
 extern struct ethtool_ops be_ethtool_ops;
drivers/net/benet/be_cmds.c +12 -7
index 0b60508..dad2d2b 100644
@@ -927,8 +927,8 @@ int be_cmd_promiscuous_config(struct be_ctrl_info *ctrl, u8 port_num, bool en)
  * Use MCC for this command as it may be called in BH context
  * (mc == NULL) => multicast promiscous
  */
-int be_cmd_mcast_mac_set(struct be_ctrl_info *ctrl, u32 if_id, u8 *mac_table,
-			u32 num, bool promiscuous)
+int be_cmd_multicast_set(struct be_ctrl_info *ctrl, u32 if_id,
+		struct dev_mc_list *mc_list, u32 mc_count)
 {
 #define BE_MAX_MC		32 /* set mcast promisc if > 32 */
 	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,
 		OPCODE_COMMON_NTWK_MULTICAST_SET, sizeof(*req));
 
 	req->interface_id = if_id;
-	req->promiscuous = promiscuous;
-	if (!promiscuous) {
-		req->num_mac = cpu_to_le16(num);
-		if (num)
-			memcpy(req->mac, mac_table, ETH_ALEN * num);
+	if (mc_list && mc_count <= BE_MAX_MC) {
+		int i;
+		struct dev_mc_list *mc;
+
+		req->num_mac = cpu_to_le16(mc_count);
+
+		for (mc = mc_list, i = 0; mc; mc = mc->next, i++)
+			memcpy(req->mac[i].byte, mc->dmi_addr, ETH_ALEN);
+	} else {
+		req->promiscuous = 1;
 	}
 
 	be_mcc_notify_wait(ctrl);
drivers/net/benet/be_cmds.h +2 -2
index 0a9189d..a567aa4 100644
@@ -716,8 +716,8 @@ extern int be_cmd_vlan_config(struct be_ctrl_info *ctrl, u32 if_id,
 			bool promiscuous);
 extern int be_cmd_promiscuous_config(struct be_ctrl_info *ctrl,
 			u8 port_num, bool en);
-extern int be_cmd_mcast_mac_set(struct be_ctrl_info *ctrl, u32 if_id,
-			u8 *mac_table, u32 num, bool promiscuous);
+extern int be_cmd_multicast_set(struct be_ctrl_info *ctrl, u32 if_id,
+			struct dev_mc_list *mc_list, u32 mc_count);
 extern int be_cmd_set_flow_control(struct be_ctrl_info *ctrl,
 			u32 tx_fc, u32 rx_fc);
 extern int be_cmd_get_flow_control(struct be_ctrl_info *ctrl,
drivers/net/benet/be_main.c +17 -32

64 lines not on this page · raw message

Signature · 1 line
1.6.0.4