Skip to content

Commit c587094

Browse files
committed
Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue
Jeff Kirsher says: ==================== 40GbE Intel Wired LAN Driver Updates 2016-10-31 This series contains updates to i40e and i40evf. Colin Ian King fixes a minor issue with dev_err message where a new line character was missing from the end of the message. Jake provides several most of the changes in the series, starting with dropping the is_vf and is_netdev fields in the i40e_mac_filter structure since they are not needed (along with the checks that used these fields). Reason being that we use separate VSI's for SRIOV VFs and for netdev VSIs, therefore a single VSI should only have one type of filter. Then simplifies our .set_rx_mode handler by using the kernel provided __dev_uc_sync and __dev_mc_sync functions for notification of add and deletion of filters. Refactored the i40e_put_mac_in_vlan() to resolve an issue where this function was arbitrarily modifying all filters to have the same VLAN, which is incorrect because it could be modifying active filters without putting them into the new state. Refactored the delete filter logic so that we can re-use the functionality, where appropriate, without having to search for the filter twice. Reduced the latency of operations related to searching for specific MAC filters by using a static hash table instead of a list. Reduced code duplication in the adminq command to add/delete for filters. Fixed an issue where TSYNVALID bit was not being checked as the true indicator of whether the packet has an associated timestamp. Cleaned up a second msleep() call by simply re-ordering the code so that the extra wait is no longer needed. Alan provides additional fix to the work Jake has been doing to resolve a bug where adding at least one VLAN and then removing all VLANs leaves the MAC filters for the VSI with an incorrect value for the VID which indicates the MAC filter's VLAN status. Alex adds a common method for finding a VSI by type. Also cleaned up the logic for coalescing RS bits, which was convoluted and larger than it needed to be. Mitch fixes an issue with the failure to add filters when the VF driver is reloaded by simply setting the number of filters to 0 when freeing VF resources. Maciej implements a I40E_NVMUPD_STATE_ERROR state for NVM update, so that the driver has the ability to return NVM image write failure. Filip removes unreachable code which was found using static analysis where "if" statements were never in a "true/false" state, so clean up unnecessary if statements. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents bd68a2a + 3aa7b74 commit c587094

18 files changed

+867
-850
lines changed

drivers/net/ethernet/intel/i40e/i40e.h

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <linux/iommu.h>
4040
#include <linux/slab.h>
4141
#include <linux/list.h>
42+
#include <linux/hashtable.h>
4243
#include <linux/string.h>
4344
#include <linux/in.h>
4445
#include <linux/ip.h>
@@ -428,11 +429,13 @@ struct i40e_pf {
428429
struct ptp_clock_info ptp_caps;
429430
struct sk_buff *ptp_tx_skb;
430431
struct hwtstamp_config tstamp_config;
431-
unsigned long last_rx_ptp_check;
432-
spinlock_t tmreg_lock; /* Used to protect the device time registers. */
432+
struct mutex tmreg_lock; /* Used to protect the SYSTIME registers. */
433433
u64 ptp_base_adj;
434434
u32 tx_hwtstamp_timeouts;
435435
u32 rx_hwtstamp_cleared;
436+
u32 latch_event_flags;
437+
spinlock_t ptp_rx_lock; /* Used to protect Rx timestamp registers. */
438+
unsigned long latch_events[4];
436439
bool ptp_tx;
437440
bool ptp_rx;
438441
u16 rss_table_size; /* HW RSS table size */
@@ -445,6 +448,20 @@ struct i40e_pf {
445448
u16 phy_led_val;
446449
};
447450

451+
/**
452+
* i40e_mac_to_hkey - Convert a 6-byte MAC Address to a u64 hash key
453+
* @macaddr: the MAC Address as the base key
454+
*
455+
* Simply copies the address and returns it as a u64 for hashing
456+
**/
457+
static inline u64 i40e_addr_to_hkey(const u8 *macaddr)
458+
{
459+
u64 key = 0;
460+
461+
ether_addr_copy((u8 *)&key, macaddr);
462+
return key;
463+
}
464+
448465
enum i40e_filter_state {
449466
I40E_FILTER_INVALID = 0, /* Invalid state */
450467
I40E_FILTER_NEW, /* New, not sent to FW yet */
@@ -454,13 +471,10 @@ enum i40e_filter_state {
454471
/* There is no 'removed' state; the filter struct is freed */
455472
};
456473
struct i40e_mac_filter {
457-
struct list_head list;
474+
struct hlist_node hlist;
458475
u8 macaddr[ETH_ALEN];
459476
#define I40E_VLAN_ANY -1
460477
s16 vlan;
461-
u8 counter; /* number of instances of this filter */
462-
bool is_vf; /* filter belongs to a VF */
463-
bool is_netdev; /* filter belongs to a netdev */
464478
enum i40e_filter_state state;
465479
};
466480

@@ -501,9 +515,11 @@ struct i40e_vsi {
501515
#define I40E_VSI_FLAG_VEB_OWNER BIT(1)
502516
unsigned long flags;
503517

504-
/* Per VSI lock to protect elements/list (MAC filter) */
505-
spinlock_t mac_filter_list_lock;
506-
struct list_head mac_filter_list;
518+
/* Per VSI lock to protect elements/hash (MAC filter) */
519+
spinlock_t mac_filter_hash_lock;
520+
/* Fixed size hash table with 2^8 buckets for MAC filters */
521+
DECLARE_HASHTABLE(mac_filter_hash, 8);
522+
bool has_vlan_filter;
507523

508524
/* VSI stats */
509525
struct rtnl_link_stats64 net_stats;
@@ -707,6 +723,25 @@ int i40e_get_rss(struct i40e_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size);
707723
void i40e_fill_rss_lut(struct i40e_pf *pf, u8 *lut,
708724
u16 rss_table_size, u16 rss_size);
709725
struct i40e_vsi *i40e_find_vsi_from_id(struct i40e_pf *pf, u16 id);
726+
/**
727+
* i40e_find_vsi_by_type - Find and return Flow Director VSI
728+
* @pf: PF to search for VSI
729+
* @type: Value indicating type of VSI we are looking for
730+
**/
731+
static inline struct i40e_vsi *
732+
i40e_find_vsi_by_type(struct i40e_pf *pf, u16 type)
733+
{
734+
int i;
735+
736+
for (i = 0; i < pf->num_alloc_vsi; i++) {
737+
struct i40e_vsi *vsi = pf->vsi[i];
738+
739+
if (vsi && vsi->type == type)
740+
return vsi;
741+
}
742+
743+
return NULL;
744+
}
710745
void i40e_update_stats(struct i40e_vsi *vsi);
711746
void i40e_update_eth_stats(struct i40e_vsi *vsi);
712747
struct rtnl_link_stats64 *i40e_get_vsi_stats_struct(struct i40e_vsi *vsi);
@@ -723,10 +758,8 @@ u32 i40e_get_global_fd_count(struct i40e_pf *pf);
723758
bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features);
724759
void i40e_set_ethtool_ops(struct net_device *netdev);
725760
struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,
726-
u8 *macaddr, s16 vlan,
727-
bool is_vf, bool is_netdev);
728-
void i40e_del_filter(struct i40e_vsi *vsi, u8 *macaddr, s16 vlan,
729-
bool is_vf, bool is_netdev);
761+
const u8 *macaddr, s16 vlan);
762+
void i40e_del_filter(struct i40e_vsi *vsi, const u8 *macaddr, s16 vlan);
730763
int i40e_sync_vsi_filters(struct i40e_vsi *vsi);
731764
struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
732765
u16 uplink, u32 param1);
@@ -740,7 +773,8 @@ void i40e_service_event_schedule(struct i40e_pf *pf);
740773
void i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id,
741774
u8 *msg, u16 len);
742775

743-
int i40e_vsi_control_rings(struct i40e_vsi *vsi, bool enable);
776+
int i40e_vsi_start_rings(struct i40e_vsi *vsi);
777+
void i40e_vsi_stop_rings(struct i40e_vsi *vsi);
744778
int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count);
745779
struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags, u16 uplink_seid,
746780
u16 downlink_seid, u8 enabled_tc);
@@ -816,14 +850,12 @@ int i40e_close(struct net_device *netdev);
816850
int i40e_vsi_open(struct i40e_vsi *vsi);
817851
void i40e_vlan_stripping_disable(struct i40e_vsi *vsi);
818852
int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid);
819-
int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid);
820-
struct i40e_mac_filter *i40e_put_mac_in_vlan(struct i40e_vsi *vsi, u8 *macaddr,
821-
bool is_vf, bool is_netdev);
822-
int i40e_del_mac_all_vlan(struct i40e_vsi *vsi, u8 *macaddr,
823-
bool is_vf, bool is_netdev);
853+
void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid);
854+
struct i40e_mac_filter *i40e_put_mac_in_vlan(struct i40e_vsi *vsi,
855+
const u8 *macaddr);
856+
int i40e_del_mac_all_vlan(struct i40e_vsi *vsi, const u8 *macaddr);
824857
bool i40e_is_vsi_in_vlan(struct i40e_vsi *vsi);
825-
struct i40e_mac_filter *i40e_find_mac(struct i40e_vsi *vsi, u8 *macaddr,
826-
bool is_vf, bool is_netdev);
858+
struct i40e_mac_filter *i40e_find_mac(struct i40e_vsi *vsi, const u8 *macaddr);
827859
#ifdef I40E_FCOE
828860
int __i40e_setup_tc(struct net_device *netdev, u32 handle, __be16 proto,
829861
struct tc_to_netdev *tc);

drivers/net/ethernet/intel/i40e/i40e_adminq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,11 +964,11 @@ i40e_status i40e_clean_arq_element(struct i40e_hw *hw,
964964
desc = I40E_ADMINQ_DESC(hw->aq.arq, ntc);
965965
desc_idx = ntc;
966966

967+
hw->aq.arq_last_status =
968+
(enum i40e_admin_queue_err)le16_to_cpu(desc->retval);
967969
flags = le16_to_cpu(desc->flags);
968970
if (flags & I40E_AQ_FLAG_ERR) {
969971
ret_code = I40E_ERR_ADMIN_QUEUE_ERROR;
970-
hw->aq.arq_last_status =
971-
(enum i40e_admin_queue_err)le16_to_cpu(desc->retval);
972972
i40e_debug(hw,
973973
I40E_DEBUG_AQ_MESSAGE,
974974
"AQRX: Event received with error 0x%X.\n",

drivers/net/ethernet/intel/i40e/i40e_common.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3313,8 +3313,10 @@ static void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
33133313
/* partition id is 1-based, and functions are evenly spread
33143314
* across the ports as partitions
33153315
*/
3316-
hw->partition_id = (hw->pf_id / hw->num_ports) + 1;
3317-
hw->num_partitions = num_functions / hw->num_ports;
3316+
if (hw->num_ports != 0) {
3317+
hw->partition_id = (hw->pf_id / hw->num_ports) + 1;
3318+
hw->num_partitions = num_functions / hw->num_ports;
3319+
}
33183320

33193321
/* additional HW specific goodies that might
33203322
* someday be HW version specific

drivers/net/ethernet/intel/i40e/i40e_debugfs.c

Lines changed: 5 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
134134
struct rtnl_link_stats64 *nstat;
135135
struct i40e_mac_filter *f;
136136
struct i40e_vsi *vsi;
137-
int i;
137+
int i, bkt;
138138

139139
vsi = i40e_dbg_find_vsi(pf, seid);
140140
if (!vsi) {
@@ -166,11 +166,11 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
166166
pf->hw.mac.addr,
167167
pf->hw.mac.san_addr,
168168
pf->hw.mac.port_addr);
169-
list_for_each_entry(f, &vsi->mac_filter_list, list) {
169+
hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) {
170170
dev_info(&pf->pdev->dev,
171-
" mac_filter_list: %pM vid=%d, is_netdev=%d is_vf=%d counter=%d, state %s\n",
172-
f->macaddr, f->vlan, f->is_netdev, f->is_vf,
173-
f->counter, i40e_filter_state_string[f->state]);
171+
" mac_filter_hash: %pM vid=%d, state %s\n",
172+
f->macaddr, f->vlan,
173+
i40e_filter_state_string[f->state]);
174174
}
175175
dev_info(&pf->pdev->dev, " active_filters %d, promisc_threshold %d, overflow promisc %s\n",
176176
vsi->active_filters, vsi->promisc_threshold,
@@ -867,86 +867,6 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
867867

868868
dev_info(&pf->pdev->dev, "deleting relay %d\n", veb_seid);
869869
i40e_veb_release(pf->veb[i]);
870-
871-
} else if (strncmp(cmd_buf, "add macaddr", 11) == 0) {
872-
struct i40e_mac_filter *f;
873-
int vlan = 0;
874-
u8 ma[6];
875-
int ret;
876-
877-
cnt = sscanf(&cmd_buf[11],
878-
"%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
879-
&vsi_seid,
880-
&ma[0], &ma[1], &ma[2], &ma[3], &ma[4], &ma[5],
881-
&vlan);
882-
if (cnt == 7) {
883-
vlan = 0;
884-
} else if (cnt != 8) {
885-
dev_info(&pf->pdev->dev,
886-
"add macaddr: bad command string, cnt=%d\n",
887-
cnt);
888-
goto command_write_done;
889-
}
890-
891-
vsi = i40e_dbg_find_vsi(pf, vsi_seid);
892-
if (!vsi) {
893-
dev_info(&pf->pdev->dev,
894-
"add macaddr: VSI %d not found\n", vsi_seid);
895-
goto command_write_done;
896-
}
897-
898-
spin_lock_bh(&vsi->mac_filter_list_lock);
899-
f = i40e_add_filter(vsi, ma, vlan, false, false);
900-
spin_unlock_bh(&vsi->mac_filter_list_lock);
901-
ret = i40e_sync_vsi_filters(vsi);
902-
if (f && !ret)
903-
dev_info(&pf->pdev->dev,
904-
"add macaddr: %pM vlan=%d added to VSI %d\n",
905-
ma, vlan, vsi_seid);
906-
else
907-
dev_info(&pf->pdev->dev,
908-
"add macaddr: %pM vlan=%d to VSI %d failed, f=%p ret=%d\n",
909-
ma, vlan, vsi_seid, f, ret);
910-
911-
} else if (strncmp(cmd_buf, "del macaddr", 11) == 0) {
912-
int vlan = 0;
913-
u8 ma[6];
914-
int ret;
915-
916-
cnt = sscanf(&cmd_buf[11],
917-
"%i %hhx:%hhx:%hhx:%hhx:%hhx:%hhx %i",
918-
&vsi_seid,
919-
&ma[0], &ma[1], &ma[2], &ma[3], &ma[4], &ma[5],
920-
&vlan);
921-
if (cnt == 7) {
922-
vlan = 0;
923-
} else if (cnt != 8) {
924-
dev_info(&pf->pdev->dev,
925-
"del macaddr: bad command string, cnt=%d\n",
926-
cnt);
927-
goto command_write_done;
928-
}
929-
930-
vsi = i40e_dbg_find_vsi(pf, vsi_seid);
931-
if (!vsi) {
932-
dev_info(&pf->pdev->dev,
933-
"del macaddr: VSI %d not found\n", vsi_seid);
934-
goto command_write_done;
935-
}
936-
937-
spin_lock_bh(&vsi->mac_filter_list_lock);
938-
i40e_del_filter(vsi, ma, vlan, false, false);
939-
spin_unlock_bh(&vsi->mac_filter_list_lock);
940-
ret = i40e_sync_vsi_filters(vsi);
941-
if (!ret)
942-
dev_info(&pf->pdev->dev,
943-
"del macaddr: %pM vlan=%d removed from VSI %d\n",
944-
ma, vlan, vsi_seid);
945-
else
946-
dev_info(&pf->pdev->dev,
947-
"del macaddr: %pM vlan=%d from VSI %d failed, ret=%d\n",
948-
ma, vlan, vsi_seid, ret);
949-
950870
} else if (strncmp(cmd_buf, "add pvid", 8) == 0) {
951871
i40e_status ret;
952872
u16 vid;
@@ -1615,8 +1535,6 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
16151535
dev_info(&pf->pdev->dev, " del vsi [vsi_seid]\n");
16161536
dev_info(&pf->pdev->dev, " add relay <uplink_seid> <vsi_seid>\n");
16171537
dev_info(&pf->pdev->dev, " del relay <relay_seid>\n");
1618-
dev_info(&pf->pdev->dev, " add macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
1619-
dev_info(&pf->pdev->dev, " del macaddr <vsi_seid> <aa:bb:cc:dd:ee:ff> [vlan]\n");
16201538
dev_info(&pf->pdev->dev, " add pvid <vsi_seid> <vid>\n");
16211539
dev_info(&pf->pdev->dev, " del pvid <vsi_seid>\n");
16221540
dev_info(&pf->pdev->dev, " dump switch\n");

drivers/net/ethernet/intel/i40e/i40e_ethtool.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,13 @@ enum i40e_ethtool_test_id {
216216
I40E_ETH_TEST_REG = 0,
217217
I40E_ETH_TEST_EEPROM,
218218
I40E_ETH_TEST_INTR,
219-
I40E_ETH_TEST_LOOPBACK,
220219
I40E_ETH_TEST_LINK,
221220
};
222221

223222
static const char i40e_gstrings_test[][ETH_GSTRING_LEN] = {
224223
"Register test (offline)",
225224
"Eeprom test (offline)",
226225
"Interrupt test (offline)",
227-
"Loopback test (offline)",
228226
"Link test (on/offline)"
229227
};
230228

@@ -1744,17 +1742,6 @@ static int i40e_intr_test(struct net_device *netdev, u64 *data)
17441742
return *data;
17451743
}
17461744

1747-
static int i40e_loopback_test(struct net_device *netdev, u64 *data)
1748-
{
1749-
struct i40e_netdev_priv *np = netdev_priv(netdev);
1750-
struct i40e_pf *pf = np->vsi->back;
1751-
1752-
netif_info(pf, hw, netdev, "loopback test not implemented\n");
1753-
*data = 0;
1754-
1755-
return *data;
1756-
}
1757-
17581745
static inline bool i40e_active_vfs(struct i40e_pf *pf)
17591746
{
17601747
struct i40e_vf *vfs = pf->vf;
@@ -1768,17 +1755,7 @@ static inline bool i40e_active_vfs(struct i40e_pf *pf)
17681755

17691756
static inline bool i40e_active_vmdqs(struct i40e_pf *pf)
17701757
{
1771-
struct i40e_vsi **vsi = pf->vsi;
1772-
int i;
1773-
1774-
for (i = 0; i < pf->num_alloc_vsi; i++) {
1775-
if (!vsi[i])
1776-
continue;
1777-
if (vsi[i]->type == I40E_VSI_VMDQ2)
1778-
return true;
1779-
}
1780-
1781-
return false;
1758+
return !!i40e_find_vsi_by_type(pf, I40E_VSI_VMDQ2);
17821759
}
17831760

17841761
static void i40e_diag_test(struct net_device *netdev,
@@ -1800,7 +1777,6 @@ static void i40e_diag_test(struct net_device *netdev,
18001777
data[I40E_ETH_TEST_REG] = 1;
18011778
data[I40E_ETH_TEST_EEPROM] = 1;
18021779
data[I40E_ETH_TEST_INTR] = 1;
1803-
data[I40E_ETH_TEST_LOOPBACK] = 1;
18041780
data[I40E_ETH_TEST_LINK] = 1;
18051781
eth_test->flags |= ETH_TEST_FL_FAILED;
18061782
clear_bit(__I40E_TESTING, &pf->state);
@@ -1828,9 +1804,6 @@ static void i40e_diag_test(struct net_device *netdev,
18281804
if (i40e_intr_test(netdev, &data[I40E_ETH_TEST_INTR]))
18291805
eth_test->flags |= ETH_TEST_FL_FAILED;
18301806

1831-
if (i40e_loopback_test(netdev, &data[I40E_ETH_TEST_LOOPBACK]))
1832-
eth_test->flags |= ETH_TEST_FL_FAILED;
1833-
18341807
/* run reg test last, a reset is required after it */
18351808
if (i40e_reg_test(netdev, &data[I40E_ETH_TEST_REG]))
18361809
eth_test->flags |= ETH_TEST_FL_FAILED;
@@ -1851,7 +1824,6 @@ static void i40e_diag_test(struct net_device *netdev,
18511824
data[I40E_ETH_TEST_REG] = 0;
18521825
data[I40E_ETH_TEST_EEPROM] = 0;
18531826
data[I40E_ETH_TEST_INTR] = 0;
1854-
data[I40E_ETH_TEST_LOOPBACK] = 0;
18551827
}
18561828

18571829
skip_ol_tests:

drivers/net/ethernet/intel/i40e/i40e_fcoe.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,12 +1522,12 @@ void i40e_fcoe_config_netdev(struct net_device *netdev, struct i40e_vsi *vsi)
15221522
* same PCI function.
15231523
*/
15241524
netdev->dev_port = 1;
1525-
spin_lock_bh(&vsi->mac_filter_list_lock);
1526-
i40e_add_filter(vsi, hw->mac.san_addr, 0, false, false);
1527-
i40e_add_filter(vsi, (u8[6]) FC_FCOE_FLOGI_MAC, 0, false, false);
1528-
i40e_add_filter(vsi, FIP_ALL_FCOE_MACS, 0, false, false);
1529-
i40e_add_filter(vsi, FIP_ALL_ENODE_MACS, 0, false, false);
1530-
spin_unlock_bh(&vsi->mac_filter_list_lock);
1525+
spin_lock_bh(&vsi->mac_filter_hash_lock);
1526+
i40e_add_filter(vsi, hw->mac.san_addr, 0);
1527+
i40e_add_filter(vsi, (u8[6]) FC_FCOE_FLOGI_MAC, 0);
1528+
i40e_add_filter(vsi, FIP_ALL_FCOE_MACS, 0);
1529+
i40e_add_filter(vsi, FIP_ALL_ENODE_MACS, 0);
1530+
spin_unlock_bh(&vsi->mac_filter_hash_lock);
15311531

15321532
/* use san mac */
15331533
ether_addr_copy(netdev->dev_addr, hw->mac.san_addr);

0 commit comments

Comments
 (0)