aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRavikumar Nelavelli <ravikumar.nelavelli@emulex.com>2014-05-09 03:59:16 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-09 13:13:39 -0400
commitf6cbd3644ac3188b422ce83f5a95a65e4450b7c6 (patch)
tree32074f04d2909e2791ff38d29195365bf4d99b02
parent05e4c6a3af71dd3848f3f54a1ccb740bdcd183e2 (diff)
be2net: covert vlan array to bit-map
This patch converts the vlan u8[] used to track vlan-id membership to a bit-map as it reduces memory usage. Signed-off-by: Ravikumar Nelavelli <ravikumar.nelavelli@emulex.com> Signed-off-by: Sathya Perla <sathya.perla@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h2
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c19
2 files changed, 10 insertions, 11 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index 2f67c7c8d413..31c376628bfd 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -455,7 +455,7 @@ struct be_adapter {
455 struct be_drv_stats drv_stats; 455 struct be_drv_stats drv_stats;
456 struct be_aic_obj aic_obj[MAX_EVT_QS]; 456 struct be_aic_obj aic_obj[MAX_EVT_QS];
457 u16 vlans_added; 457 u16 vlans_added;
458 u8 vlan_tag[VLAN_N_VID]; 458 unsigned long vids[BITS_TO_LONGS(VLAN_N_VID)];
459 u8 vlan_prio_bmap; /* Available Priority BitMap */ 459 u8 vlan_prio_bmap; /* Available Priority BitMap */
460 u16 recommended_prio; /* Recommended Priority */ 460 u16 recommended_prio; /* Recommended Priority */
461 struct be_dma_mem rx_filter; /* Cmd DMA mem for rx-filter */ 461 struct be_dma_mem rx_filter; /* Cmd DMA mem for rx-filter */
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 8dc1af47c59a..2cd733b5de73 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1094,7 +1094,7 @@ static int be_change_mtu(struct net_device *netdev, int new_mtu)
1094static int be_vid_config(struct be_adapter *adapter) 1094static int be_vid_config(struct be_adapter *adapter)
1095{ 1095{
1096 u16 vids[BE_NUM_VLANS_SUPPORTED]; 1096 u16 vids[BE_NUM_VLANS_SUPPORTED];
1097 u16 num = 0, i; 1097 u16 num = 0, i = 0;
1098 int status = 0; 1098 int status = 0;
1099 1099
1100 /* No need to further configure vids if in promiscuous mode */ 1100 /* No need to further configure vids if in promiscuous mode */
@@ -1105,9 +1105,8 @@ static int be_vid_config(struct be_adapter *adapter)
1105 goto set_vlan_promisc; 1105 goto set_vlan_promisc;
1106 1106
1107 /* Construct VLAN Table to give to HW */ 1107 /* Construct VLAN Table to give to HW */
1108 for (i = 0; i < VLAN_N_VID; i++) 1108 for_each_set_bit(i, adapter->vids, VLAN_N_VID)
1109 if (adapter->vlan_tag[i]) 1109 vids[num++] = cpu_to_le16(i);
1110 vids[num++] = cpu_to_le16(i);
1111 1110
1112 status = be_cmd_vlan_config(adapter, adapter->if_handle, vids, num, 0); 1111 status = be_cmd_vlan_config(adapter, adapter->if_handle, vids, num, 0);
1113 1112
@@ -1155,16 +1154,16 @@ static int be_vlan_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
1155 if (lancer_chip(adapter) && vid == 0) 1154 if (lancer_chip(adapter) && vid == 0)
1156 return status; 1155 return status;
1157 1156
1158 if (adapter->vlan_tag[vid]) 1157 if (test_bit(vid, adapter->vids))
1159 return status; 1158 return status;
1160 1159
1161 adapter->vlan_tag[vid] = 1; 1160 set_bit(vid, adapter->vids);
1162 adapter->vlans_added++; 1161 adapter->vlans_added++;
1163 1162
1164 status = be_vid_config(adapter); 1163 status = be_vid_config(adapter);
1165 if (status) { 1164 if (status) {
1166 adapter->vlans_added--; 1165 adapter->vlans_added--;
1167 adapter->vlan_tag[vid] = 0; 1166 clear_bit(vid, adapter->vids);
1168 } 1167 }
1169 1168
1170 return status; 1169 return status;
@@ -1179,12 +1178,12 @@ static int be_vlan_rem_vid(struct net_device *netdev, __be16 proto, u16 vid)
1179 if (lancer_chip(adapter) && vid == 0) 1178 if (lancer_chip(adapter) && vid == 0)
1180 goto ret; 1179 goto ret;
1181 1180
1182 adapter->vlan_tag[vid] = 0; 1181 clear_bit(vid, adapter->vids);
1183 status = be_vid_config(adapter); 1182 status = be_vid_config(adapter);
1184 if (!status) 1183 if (!status)
1185 adapter->vlans_added--; 1184 adapter->vlans_added--;
1186 else 1185 else
1187 adapter->vlan_tag[vid] = 1; 1186 set_bit(vid, adapter->vids);
1188ret: 1187ret:
1189 return status; 1188 return status;
1190} 1189}
@@ -1795,7 +1794,7 @@ static struct be_rx_compl_info *be_rx_compl_get(struct be_rx_obj *rxo)
1795 rxcp->vlan_tag = swab16(rxcp->vlan_tag); 1794 rxcp->vlan_tag = swab16(rxcp->vlan_tag);
1796 1795
1797 if (adapter->pvid == (rxcp->vlan_tag & VLAN_VID_MASK) && 1796 if (adapter->pvid == (rxcp->vlan_tag & VLAN_VID_MASK) &&
1798 !adapter->vlan_tag[rxcp->vlan_tag]) 1797 !test_bit(rxcp->vlan_tag, adapter->vids))
1799 rxcp->vlanf = 0; 1798 rxcp->vlanf = 0;
1800 } 1799 }
1801 1800