aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/emulex
diff options
context:
space:
mode:
authorSathya Perla <sathya.perla@emulex.com>2015-02-06 08:18:40 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-08 01:50:58 -0500
commitac34b74378a15b01d16ae84d616b405dd0948ecb (patch)
tree246ab612e02a28271ed4e5f9ae18ab233766fe5d /drivers/net/ethernet/emulex
parent70a7b5257018c518007c7212977bab6ccacd9468 (diff)
be2net: remove duplicate code in be_cmd_rx_filter()
This patch passes BE_IF_FLAGS_XXX flags to be_cmd_rx_filter() routine instead of the IFF_XXX flags. Doing this gets rid of the code to convert the IFF_XXX flags to the BE_IF_FLAGS_XXX used by the FW cmd. The patch also removes code for setting if_flags_mask that was duplicated for each filter mode. Signed-off-by: Sathya Perla <sathya.perla@emulex.com> Signed-off-by: Kalesh AP <kalesh.purayil@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/emulex')
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c54
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h4
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c29
3 files changed, 36 insertions, 51 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 03119ac548f6..ceae6235e707 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1886,7 +1886,7 @@ err:
1886 return status; 1886 return status;
1887} 1887}
1888 1888
1889int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value) 1889static int __be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value)
1890{ 1890{
1891 struct be_mcc_wrb *wrb; 1891 struct be_mcc_wrb *wrb;
1892 struct be_dma_mem *mem = &adapter->rx_filter; 1892 struct be_dma_mem *mem = &adapter->rx_filter;
@@ -1906,31 +1906,13 @@ int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value)
1906 wrb, mem); 1906 wrb, mem);
1907 1907
1908 req->if_id = cpu_to_le32(adapter->if_handle); 1908 req->if_id = cpu_to_le32(adapter->if_handle);
1909 if (flags & IFF_PROMISC) { 1909 req->if_flags_mask = cpu_to_le32(flags);
1910 req->if_flags_mask = cpu_to_le32(BE_IF_FLAGS_PROMISCUOUS | 1910 req->if_flags = (value == ON) ? req->if_flags_mask : 0;
1911 BE_IF_FLAGS_VLAN_PROMISCUOUS | 1911
1912 BE_IF_FLAGS_MCAST_PROMISCUOUS); 1912 if (flags & BE_IF_FLAGS_MULTICAST) {
1913 if (value == ON)
1914 req->if_flags =
1915 cpu_to_le32(BE_IF_FLAGS_PROMISCUOUS |
1916 BE_IF_FLAGS_VLAN_PROMISCUOUS |
1917 BE_IF_FLAGS_MCAST_PROMISCUOUS);
1918 } else if (flags & IFF_ALLMULTI) {
1919 req->if_flags_mask = cpu_to_le32(BE_IF_FLAGS_MCAST_PROMISCUOUS);
1920 req->if_flags = cpu_to_le32(BE_IF_FLAGS_MCAST_PROMISCUOUS);
1921 } else if (flags & BE_FLAGS_VLAN_PROMISC) {
1922 req->if_flags_mask = cpu_to_le32(BE_IF_FLAGS_VLAN_PROMISCUOUS);
1923
1924 if (value == ON)
1925 req->if_flags =
1926 cpu_to_le32(BE_IF_FLAGS_VLAN_PROMISCUOUS);
1927 } else {
1928 struct netdev_hw_addr *ha; 1913 struct netdev_hw_addr *ha;
1929 int i = 0; 1914 int i = 0;
1930 1915
1931 req->if_flags_mask = cpu_to_le32(BE_IF_FLAGS_MULTICAST);
1932 req->if_flags = cpu_to_le32(BE_IF_FLAGS_MULTICAST);
1933
1934 /* Reset mcast promisc mode if already set by setting mask 1916 /* Reset mcast promisc mode if already set by setting mask
1935 * and not setting flags field 1917 * and not setting flags field
1936 */ 1918 */
@@ -1942,24 +1924,26 @@ int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value)
1942 memcpy(req->mcast_mac[i++].byte, ha->addr, ETH_ALEN); 1924 memcpy(req->mcast_mac[i++].byte, ha->addr, ETH_ALEN);
1943 } 1925 }
1944 1926
1945 if ((req->if_flags_mask & cpu_to_le32(be_if_cap_flags(adapter))) !=
1946 req->if_flags_mask) {
1947 dev_warn(&adapter->pdev->dev,
1948 "Cannot set rx filter flags 0x%x\n",
1949 req->if_flags_mask);
1950 dev_warn(&adapter->pdev->dev,
1951 "Interface is capable of 0x%x flags only\n",
1952 be_if_cap_flags(adapter));
1953 }
1954 req->if_flags_mask &= cpu_to_le32(be_if_cap_flags(adapter));
1955
1956 status = be_mcc_notify_wait(adapter); 1927 status = be_mcc_notify_wait(adapter);
1957
1958err: 1928err:
1959 spin_unlock_bh(&adapter->mcc_lock); 1929 spin_unlock_bh(&adapter->mcc_lock);
1960 return status; 1930 return status;
1961} 1931}
1962 1932
1933int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value)
1934{
1935 struct device *dev = &adapter->pdev->dev;
1936
1937 if ((flags & be_if_cap_flags(adapter)) != flags) {
1938 dev_warn(dev, "Cannot set rx filter flags 0x%x\n", flags);
1939 dev_warn(dev, "Interface is capable of 0x%x flags only\n",
1940 be_if_cap_flags(adapter));
1941 }
1942 flags &= be_if_cap_flags(adapter);
1943
1944 return __be_cmd_rx_filter(adapter, flags, value);
1945}
1946
1963/* Uses synchrounous mcc */ 1947/* Uses synchrounous mcc */
1964int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc) 1948int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc)
1965{ 1949{
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 402d64f5bb7c..cf9d87086546 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -586,6 +586,10 @@ enum be_if_flags {
586 BE_IF_FLAGS_PASS_L3L4_ERRORS | BE_IF_FLAGS_MULTICAST |\ 586 BE_IF_FLAGS_PASS_L3L4_ERRORS | BE_IF_FLAGS_MULTICAST |\
587 BE_IF_FLAGS_UNTAGGED) 587 BE_IF_FLAGS_UNTAGGED)
588 588
589#define BE_IF_FLAGS_ALL_PROMISCUOUS (BE_IF_FLAGS_PROMISCUOUS | \
590 BE_IF_FLAGS_VLAN_PROMISCUOUS |\
591 BE_IF_FLAGS_MCAST_PROMISCUOUS)
592
589/* An RX interface is an object with one or more MAC addresses and 593/* An RX interface is an object with one or more MAC addresses and
590 * filtering capabilities. */ 594 * filtering capabilities. */
591struct be_cmd_req_if_create { 595struct be_cmd_req_if_create {
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 01571da9cd12..a75eb7487240 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -1133,16 +1133,12 @@ static int be_vid_config(struct be_adapter *adapter)
1133 MCC_ADDL_STATUS_INSUFFICIENT_RESOURCES) 1133 MCC_ADDL_STATUS_INSUFFICIENT_RESOURCES)
1134 goto set_vlan_promisc; 1134 goto set_vlan_promisc;
1135 dev_err(dev, "Setting HW VLAN filtering failed\n"); 1135 dev_err(dev, "Setting HW VLAN filtering failed\n");
1136 } else { 1136 } else if (adapter->flags & BE_FLAGS_VLAN_PROMISC) {
1137 if (adapter->flags & BE_FLAGS_VLAN_PROMISC) { 1137 status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_VLAN_PROMISCUOUS,
1138 /* hw VLAN filtering re-enabled. */ 1138 OFF);
1139 status = be_cmd_rx_filter(adapter, 1139 if (!status) {
1140 BE_FLAGS_VLAN_PROMISC, OFF); 1140 dev_info(dev, "Disabling VLAN Promiscuous mode\n");
1141 if (!status) { 1141 adapter->flags &= ~BE_FLAGS_VLAN_PROMISC;
1142 dev_info(dev,
1143 "Disabling VLAN Promiscuous mode\n");
1144 adapter->flags &= ~BE_FLAGS_VLAN_PROMISC;
1145 }
1146 } 1142 }
1147 } 1143 }
1148 1144
@@ -1152,7 +1148,7 @@ set_vlan_promisc:
1152 if (adapter->flags & BE_FLAGS_VLAN_PROMISC) 1148 if (adapter->flags & BE_FLAGS_VLAN_PROMISC)
1153 return 0; 1149 return 0;
1154 1150
1155 status = be_cmd_rx_filter(adapter, BE_FLAGS_VLAN_PROMISC, ON); 1151 status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_VLAN_PROMISCUOUS, ON);
1156 if (!status) { 1152 if (!status) {
1157 dev_info(dev, "Enable VLAN Promiscuous mode\n"); 1153 dev_info(dev, "Enable VLAN Promiscuous mode\n");
1158 adapter->flags |= BE_FLAGS_VLAN_PROMISC; 1154 adapter->flags |= BE_FLAGS_VLAN_PROMISC;
@@ -1204,7 +1200,7 @@ static void be_clear_promisc(struct be_adapter *adapter)
1204 adapter->promiscuous = false; 1200 adapter->promiscuous = false;
1205 adapter->flags &= ~(BE_FLAGS_VLAN_PROMISC | BE_FLAGS_MCAST_PROMISC); 1201 adapter->flags &= ~(BE_FLAGS_VLAN_PROMISC | BE_FLAGS_MCAST_PROMISC);
1206 1202
1207 be_cmd_rx_filter(adapter, IFF_PROMISC, OFF); 1203 be_cmd_rx_filter(adapter, BE_IF_FLAGS_ALL_PROMISCUOUS, OFF);
1208} 1204}
1209 1205
1210static void be_set_rx_mode(struct net_device *netdev) 1206static void be_set_rx_mode(struct net_device *netdev)
@@ -1213,7 +1209,7 @@ static void be_set_rx_mode(struct net_device *netdev)
1213 int status; 1209 int status;
1214 1210
1215 if (netdev->flags & IFF_PROMISC) { 1211 if (netdev->flags & IFF_PROMISC) {
1216 be_cmd_rx_filter(adapter, IFF_PROMISC, ON); 1212 be_cmd_rx_filter(adapter, BE_IF_FLAGS_ALL_PROMISCUOUS, ON);
1217 adapter->promiscuous = true; 1213 adapter->promiscuous = true;
1218 goto done; 1214 goto done;
1219 } 1215 }
@@ -1240,7 +1236,8 @@ static void be_set_rx_mode(struct net_device *netdev)
1240 } 1236 }
1241 1237
1242 if (netdev_uc_count(netdev) > be_max_uc(adapter)) { 1238 if (netdev_uc_count(netdev) > be_max_uc(adapter)) {
1243 be_cmd_rx_filter(adapter, IFF_PROMISC, ON); 1239 be_cmd_rx_filter(adapter, BE_IF_FLAGS_ALL_PROMISCUOUS,
1240 ON);
1244 adapter->promiscuous = true; 1241 adapter->promiscuous = true;
1245 goto done; 1242 goto done;
1246 } 1243 }
@@ -1253,7 +1250,7 @@ static void be_set_rx_mode(struct net_device *netdev)
1253 } 1250 }
1254 } 1251 }
1255 1252
1256 status = be_cmd_rx_filter(adapter, IFF_MULTICAST, ON); 1253 status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_MULTICAST, ON);
1257 if (!status) { 1254 if (!status) {
1258 if (adapter->flags & BE_FLAGS_MCAST_PROMISC) 1255 if (adapter->flags & BE_FLAGS_MCAST_PROMISC)
1259 adapter->flags &= ~BE_FLAGS_MCAST_PROMISC; 1256 adapter->flags &= ~BE_FLAGS_MCAST_PROMISC;
@@ -1267,7 +1264,7 @@ set_mcast_promisc:
1267 /* Set to MCAST promisc mode if setting MULTICAST address fails 1264 /* Set to MCAST promisc mode if setting MULTICAST address fails
1268 * or if num configured exceeds what we support 1265 * or if num configured exceeds what we support
1269 */ 1266 */
1270 status = be_cmd_rx_filter(adapter, IFF_ALLMULTI, ON); 1267 status = be_cmd_rx_filter(adapter, BE_IF_FLAGS_MCAST_PROMISCUOUS, ON);
1271 if (!status) 1268 if (!status)
1272 adapter->flags |= BE_FLAGS_MCAST_PROMISC; 1269 adapter->flags |= BE_FLAGS_MCAST_PROMISC;
1273done: 1270done: