be2net: covert vlan array to bit-map
authorRavikumar Nelavelli <ravikumar.nelavelli@emulex.com>
Fri, 9 May 2014 07:59:16 +0000 (13:29 +0530)
committerDavid S. Miller <davem@davemloft.net>
Fri, 9 May 2014 17:13:39 +0000 (13:13 -0400)
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>
drivers/net/ethernet/emulex/benet/be.h
drivers/net/ethernet/emulex/benet/be_main.c

index 2f67c7c8d41337ba5240f087b56606f842360936..31c376628bfdac0158f61aef1aef3ee1aaac7e1b 100644 (file)
@@ -455,7 +455,7 @@ struct be_adapter {
        struct be_drv_stats drv_stats;
        struct be_aic_obj aic_obj[MAX_EVT_QS];
        u16 vlans_added;
-       u8 vlan_tag[VLAN_N_VID];
+       unsigned long vids[BITS_TO_LONGS(VLAN_N_VID)];
        u8 vlan_prio_bmap;      /* Available Priority BitMap */
        u16 recommended_prio;   /* Recommended Priority */
        struct be_dma_mem rx_filter; /* Cmd DMA mem for rx-filter */
index 8dc1af47c59a42b1310c8803ab1d3ca4df973780..2cd733b5de73c0d3edfe122c60f4d8bbf05034a1 100644 (file)
@@ -1094,7 +1094,7 @@ static int be_change_mtu(struct net_device *netdev, int new_mtu)
 static int be_vid_config(struct be_adapter *adapter)
 {
        u16 vids[BE_NUM_VLANS_SUPPORTED];
-       u16 num = 0, i;
+       u16 num = 0, i = 0;
        int status = 0;
 
        /* No need to further configure vids if in promiscuous mode */
@@ -1105,9 +1105,8 @@ static int be_vid_config(struct be_adapter *adapter)
                goto set_vlan_promisc;
 
        /* Construct VLAN Table to give to HW */
-       for (i = 0; i < VLAN_N_VID; i++)
-               if (adapter->vlan_tag[i])
-                       vids[num++] = cpu_to_le16(i);
+       for_each_set_bit(i, adapter->vids, VLAN_N_VID)
+               vids[num++] = cpu_to_le16(i);
 
        status = be_cmd_vlan_config(adapter, adapter->if_handle, vids, num, 0);
 
@@ -1155,16 +1154,16 @@ static int be_vlan_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
        if (lancer_chip(adapter) && vid == 0)
                return status;
 
-       if (adapter->vlan_tag[vid])
+       if (test_bit(vid, adapter->vids))
                return status;
 
-       adapter->vlan_tag[vid] = 1;
+       set_bit(vid, adapter->vids);
        adapter->vlans_added++;
 
        status = be_vid_config(adapter);
        if (status) {
                adapter->vlans_added--;
-               adapter->vlan_tag[vid] = 0;
+               clear_bit(vid, adapter->vids);
        }
 
        return status;
@@ -1179,12 +1178,12 @@ static int be_vlan_rem_vid(struct net_device *netdev, __be16 proto, u16 vid)
        if (lancer_chip(adapter) && vid == 0)
                goto ret;
 
-       adapter->vlan_tag[vid] = 0;
+       clear_bit(vid, adapter->vids);
        status = be_vid_config(adapter);
        if (!status)
                adapter->vlans_added--;
        else
-               adapter->vlan_tag[vid] = 1;
+               set_bit(vid, adapter->vids);
 ret:
        return status;
 }
@@ -1795,7 +1794,7 @@ static struct be_rx_compl_info *be_rx_compl_get(struct be_rx_obj *rxo)
                        rxcp->vlan_tag = swab16(rxcp->vlan_tag);
 
                if (adapter->pvid == (rxcp->vlan_tag & VLAN_VID_MASK) &&
-                   !adapter->vlan_tag[rxcp->vlan_tag])
+                   !test_bit(rxcp->vlan_tag, adapter->vids))
                        rxcp->vlanf = 0;
        }