aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/benet
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/benet')
-rw-r--r--drivers/net/benet/be.h14
-rw-r--r--drivers/net/benet/be_ethtool.c3
-rw-r--r--drivers/net/benet/be_main.c62
3 files changed, 72 insertions, 7 deletions
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h
index 53306bf3f401..4faf6961dcec 100644
--- a/drivers/net/benet/be.h
+++ b/drivers/net/benet/be.h
@@ -414,6 +414,20 @@ static inline void be_check_sriov_fn_type(struct be_adapter *adapter)
414 adapter->is_virtfn = (data != 0xAA); 414 adapter->is_virtfn = (data != 0xAA);
415} 415}
416 416
417static inline void be_vf_eth_addr_generate(struct be_adapter *adapter, u8 *mac)
418{
419 u32 addr;
420
421 addr = jhash(adapter->netdev->dev_addr, ETH_ALEN, 0);
422
423 mac[5] = (u8)(addr & 0xFF);
424 mac[4] = (u8)((addr >> 8) & 0xFF);
425 mac[3] = (u8)((addr >> 16) & 0xFF);
426 mac[2] = 0xC9;
427 mac[1] = 0x00;
428 mac[0] = 0x00;
429}
430
417extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, 431extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm,
418 u16 num_popped); 432 u16 num_popped);
419extern void be_link_status_update(struct be_adapter *adapter, bool link_up); 433extern void be_link_status_update(struct be_adapter *adapter, bool link_up);
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c
index 13f0abbc5205..d92063420c25 100644
--- a/drivers/net/benet/be_ethtool.c
+++ b/drivers/net/benet/be_ethtool.c
@@ -91,6 +91,9 @@ static const struct be_ethtool_stat et_stats[] = {
91 {PORTSTAT_INFO(rx_non_rss_packets)}, 91 {PORTSTAT_INFO(rx_non_rss_packets)},
92 {PORTSTAT_INFO(rx_ipv4_packets)}, 92 {PORTSTAT_INFO(rx_ipv4_packets)},
93 {PORTSTAT_INFO(rx_ipv6_packets)}, 93 {PORTSTAT_INFO(rx_ipv6_packets)},
94 {PORTSTAT_INFO(rx_switched_unicast_packets)},
95 {PORTSTAT_INFO(rx_switched_multicast_packets)},
96 {PORTSTAT_INFO(rx_switched_broadcast_packets)},
94 {PORTSTAT_INFO(tx_unicastframes)}, 97 {PORTSTAT_INFO(tx_unicastframes)},
95 {PORTSTAT_INFO(tx_multicastframes)}, 98 {PORTSTAT_INFO(tx_multicastframes)},
96 {PORTSTAT_INFO(tx_broadcastframes)}, 99 {PORTSTAT_INFO(tx_broadcastframes)},
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index 6eda7a022256..43a3a574e2e0 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -365,11 +365,6 @@ static void be_rx_eqd_update(struct be_adapter *adapter)
365 rx_eq->cur_eqd = eqd; 365 rx_eq->cur_eqd = eqd;
366} 366}
367 367
368static struct net_device_stats *be_get_stats(struct net_device *dev)
369{
370 return &dev->stats;
371}
372
373static u32 be_calc_rate(u64 bytes, unsigned long ticks) 368static u32 be_calc_rate(u64 bytes, unsigned long ticks)
374{ 369{
375 u64 rate = bytes; 370 u64 rate = bytes;
@@ -1026,7 +1021,7 @@ static void be_rx_compl_process(struct be_adapter *adapter,
1026 skb_fill_rx_data(adapter, skb, rxcp, num_rcvd); 1021 skb_fill_rx_data(adapter, skb, rxcp, num_rcvd);
1027 1022
1028 if (do_pkt_csum(rxcp, adapter->rx_csum)) 1023 if (do_pkt_csum(rxcp, adapter->rx_csum))
1029 skb->ip_summed = CHECKSUM_NONE; 1024 skb_checksum_none_assert(skb);
1030 else 1025 else
1031 skb->ip_summed = CHECKSUM_UNNECESSARY; 1026 skb->ip_summed = CHECKSUM_UNNECESSARY;
1032 1027
@@ -2084,6 +2079,47 @@ static int be_setup_wol(struct be_adapter *adapter, bool enable)
2084 return status; 2079 return status;
2085} 2080}
2086 2081
2082/*
2083 * Generate a seed MAC address from the PF MAC Address using jhash.
2084 * MAC Address for VFs are assigned incrementally starting from the seed.
2085 * These addresses are programmed in the ASIC by the PF and the VF driver
2086 * queries for the MAC address during its probe.
2087 */
2088static inline int be_vf_eth_addr_config(struct be_adapter *adapter)
2089{
2090 u32 vf = 0;
2091 int status;
2092 u8 mac[ETH_ALEN];
2093
2094 be_vf_eth_addr_generate(adapter, mac);
2095
2096 for (vf = 0; vf < num_vfs; vf++) {
2097 status = be_cmd_pmac_add(adapter, mac,
2098 adapter->vf_cfg[vf].vf_if_handle,
2099 &adapter->vf_cfg[vf].vf_pmac_id);
2100 if (status)
2101 dev_err(&adapter->pdev->dev,
2102 "Mac address add failed for VF %d\n", vf);
2103 else
2104 memcpy(adapter->vf_cfg[vf].vf_mac_addr, mac, ETH_ALEN);
2105
2106 mac[5] += 1;
2107 }
2108 return status;
2109}
2110
2111static inline void be_vf_eth_addr_rem(struct be_adapter *adapter)
2112{
2113 u32 vf;
2114
2115 for (vf = 0; vf < num_vfs; vf++) {
2116 if (adapter->vf_cfg[vf].vf_pmac_id != BE_INVALID_PMAC_ID)
2117 be_cmd_pmac_del(adapter,
2118 adapter->vf_cfg[vf].vf_if_handle,
2119 adapter->vf_cfg[vf].vf_pmac_id);
2120 }
2121}
2122
2087static int be_setup(struct be_adapter *adapter) 2123static int be_setup(struct be_adapter *adapter)
2088{ 2124{
2089 struct net_device *netdev = adapter->netdev; 2125 struct net_device *netdev = adapter->netdev;
@@ -2143,10 +2179,20 @@ static int be_setup(struct be_adapter *adapter)
2143 if (status != 0) 2179 if (status != 0)
2144 goto rx_qs_destroy; 2180 goto rx_qs_destroy;
2145 2181
2182 if (be_physfn(adapter)) {
2183 status = be_vf_eth_addr_config(adapter);
2184 if (status)
2185 goto mcc_q_destroy;
2186 }
2187
2146 adapter->link_speed = -1; 2188 adapter->link_speed = -1;
2147 2189
2148 return 0; 2190 return 0;
2149 2191
2192mcc_q_destroy:
2193 if (be_physfn(adapter))
2194 be_vf_eth_addr_rem(adapter);
2195 be_mcc_queues_destroy(adapter);
2150rx_qs_destroy: 2196rx_qs_destroy:
2151 be_rx_queues_destroy(adapter); 2197 be_rx_queues_destroy(adapter);
2152tx_qs_destroy: 2198tx_qs_destroy:
@@ -2163,6 +2209,9 @@ do_none:
2163 2209
2164static int be_clear(struct be_adapter *adapter) 2210static int be_clear(struct be_adapter *adapter)
2165{ 2211{
2212 if (be_physfn(adapter))
2213 be_vf_eth_addr_rem(adapter);
2214
2166 be_mcc_queues_destroy(adapter); 2215 be_mcc_queues_destroy(adapter);
2167 be_rx_queues_destroy(adapter); 2216 be_rx_queues_destroy(adapter);
2168 be_tx_queues_destroy(adapter); 2217 be_tx_queues_destroy(adapter);
@@ -2390,7 +2439,6 @@ static struct net_device_ops be_netdev_ops = {
2390 .ndo_open = be_open, 2439 .ndo_open = be_open,
2391 .ndo_stop = be_close, 2440 .ndo_stop = be_close,
2392 .ndo_start_xmit = be_xmit, 2441 .ndo_start_xmit = be_xmit,
2393 .ndo_get_stats = be_get_stats,
2394 .ndo_set_rx_mode = be_set_multicast_list, 2442 .ndo_set_rx_mode = be_set_multicast_list,
2395 .ndo_set_mac_address = be_mac_addr_set, 2443 .ndo_set_mac_address = be_mac_addr_set,
2396 .ndo_change_mtu = be_change_mtu, 2444 .ndo_change_mtu = be_change_mtu,