Skip to content

Commit

Permalink
Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/…
Browse files Browse the repository at this point in the history
…jkirsher/next-queue

Jeff Kirsher says:

====================
1GbE Intel Wired LAN Driver Updates 2020-05-19

This series contains updates to igc only.

Sasha cleans up the igc driver code that is not used or needed.

Vitaly cleans up driver code that was used to support Virtualization on
a device that is not supported by igc, so remove the dead code.

Andre renames a few macros to align with register and field names
described in the data sheet.  Also adds the VLAN Priority Queue Fliter
and EType Queue Filter registers to the list of registers dumped by
igc_get_regs().  Added additional debug messages and updated return codes
for unsupported features.  Refactored the VLAN priority filtering code to
move the core logic into igc_main.c.  Cleaned up duplicate code and
useless code.
====================

Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed May 21, 2020
2 parents c536fc7 + e526421 commit de1b99e
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 163 deletions.
9 changes: 6 additions & 3 deletions drivers/net/ethernet/intel/igc/igc.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void igc_set_ethtool_ops(struct net_device *);
#define MAX_Q_VECTORS 8
#define MAX_STD_JUMBO_FRAME_SIZE 9216

#define MAX_ETYPE_FILTER (4 - 1)
#define MAX_ETYPE_FILTER 8
#define IGC_RETA_SIZE 128

struct igc_tx_queue_stats {
Expand Down Expand Up @@ -189,7 +189,6 @@ struct igc_adapter {

/* lock for RX network flow classification filter */
spinlock_t nfc_lock;
bool etype_bitmap[MAX_ETYPE_FILTER];

struct igc_mac_addr *mac_table;

Expand Down Expand Up @@ -235,6 +234,11 @@ int igc_add_mac_filter(struct igc_adapter *adapter, const u8 *addr,
const s8 queue, const u8 flags);
int igc_del_mac_filter(struct igc_adapter *adapter, const u8 *addr,
const u8 flags);
int igc_add_vlan_prio_filter(struct igc_adapter *adapter, int prio,
int queue);
void igc_del_vlan_prio_filter(struct igc_adapter *adapter, int prio);
int igc_add_etype_filter(struct igc_adapter *adapter, u16 etype, int queue);
int igc_del_etype_filter(struct igc_adapter *adapter, u16 etype);
void igc_update_stats(struct igc_adapter *adapter);

/* igc_dump declarations */
Expand Down Expand Up @@ -463,7 +467,6 @@ struct igc_nfc_filter {
struct hlist_node nfc_node;
struct igc_nfc_input filter;
unsigned long cookie;
u16 etype_reg_index;
u16 sw_idx;
u16 action;
};
Expand Down
15 changes: 3 additions & 12 deletions drivers/net/ethernet/intel/igc/igc_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,6 @@

/* For checksumming, the sum of all words in the NVM should equal 0xBABA. */
#define NVM_SUM 0xBABA

#define NVM_PBA_OFFSET_0 8
#define NVM_PBA_OFFSET_1 9
#define NVM_RESERVED_WORD 0xFFFF
#define NVM_PBA_PTR_GUARD 0xFAFA
#define NVM_WORD_SIZE_BASE_SHIFT 6

/* Collision related configuration parameters */
Expand Down Expand Up @@ -249,7 +244,6 @@
/* Interrupt Cause Set */
#define IGC_ICS_LSC IGC_ICR_LSC /* Link Status Change */
#define IGC_ICS_RXDMT0 IGC_ICR_RXDMT0 /* rx desc min. threshold */
#define IGC_ICS_DRSTA IGC_ICR_DRSTA /* Device Reset Aserted */

#define IGC_ICR_DOUTSYNC 0x10000000 /* NIC DMA out of sync */
#define IGC_EITR_CNT_IGNR 0x80000000 /* Don't reset counters on write */
Expand Down Expand Up @@ -389,9 +383,6 @@

#define IGC_TSICR_INTERRUPTS IGC_TSICR_TXTS

/* PTP Queue Filter */
#define IGC_ETQF_1588 BIT(30)

#define IGC_FTQF_VF_BP 0x00008000
#define IGC_FTQF_1588_TIME_STAMP 0x08000000
#define IGC_FTQF_MASK 0xF0000000
Expand Down Expand Up @@ -513,9 +504,9 @@
#define IGC_MAX_MAC_HDR_LEN 127
#define IGC_MAX_NETWORK_HDR_LEN 511

#define IGC_VLAPQF_QUEUE_SEL(_n, q_idx) ((q_idx) << ((_n) * 4))
#define IGC_VLAPQF_P_VALID(_n) (0x1 << (3 + (_n) * 4))
#define IGC_VLAPQF_QUEUE_MASK 0x03
#define IGC_VLANPQF_QSEL(_n, q_idx) ((q_idx) << ((_n) * 4))
#define IGC_VLANPQF_VALID(_n) (0x1 << (3 + (_n) * 4))
#define IGC_VLANPQF_QUEUE_MASK 0x03

#define IGC_ADVTXD_MACLEN_SHIFT 9 /* Adv ctxt desc mac len shift */
#define IGC_ADVTXD_TUCMD_IPV4 0x00000400 /* IP Packet Type:1=IPv4 */
Expand Down
4 changes: 0 additions & 4 deletions drivers/net/ethernet/intel/igc/igc_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ static const struct igc_reg_info igc_reg_info_tbl[] = {
{IGC_TDH(0), "TDH"},
{IGC_TDT(0), "TDT"},
{IGC_TXDCTL(0), "TXDCTL"},
{IGC_TDFH, "TDFH"},
{IGC_TDFT, "TDFT"},
{IGC_TDFHS, "TDFHS"},
{IGC_TDFPC, "TDFPC"},

/* List Terminator */
{}
Expand Down
140 changes: 28 additions & 112 deletions drivers/net/ethernet/intel/igc/igc_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ static void igc_get_regs(struct net_device *netdev,
regs_buff[172 + i] = rd32(IGC_RAL(i));
for (i = 0; i < 16; i++)
regs_buff[188 + i] = rd32(IGC_RAH(i));

regs_buff[204] = rd32(IGC_VLANPQF);

for (i = 0; i < 8; i++)
regs_buff[205 + i] = rd32(IGC_ETQF(i));
}

static void igc_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
Expand Down Expand Up @@ -1181,75 +1186,6 @@ static int igc_set_rss_hash_opt(struct igc_adapter *adapter,
return 0;
}

static int igc_rxnfc_write_etype_filter(struct igc_adapter *adapter,
struct igc_nfc_filter *input)
{
struct igc_hw *hw = &adapter->hw;
u8 i;
u32 etqf;
u16 etype;

/* find an empty etype filter register */
for (i = 0; i < MAX_ETYPE_FILTER; ++i) {
if (!adapter->etype_bitmap[i])
break;
}
if (i == MAX_ETYPE_FILTER) {
netdev_err(adapter->netdev,
"ethtool -N: etype filters are all used\n");
return -EINVAL;
}

adapter->etype_bitmap[i] = true;

etqf = rd32(IGC_ETQF(i));
etype = ntohs(input->filter.etype & ETHER_TYPE_FULL_MASK);

etqf |= IGC_ETQF_FILTER_ENABLE;
etqf &= ~IGC_ETQF_ETYPE_MASK;
etqf |= (etype & IGC_ETQF_ETYPE_MASK);

etqf &= ~IGC_ETQF_QUEUE_MASK;
etqf |= ((input->action << IGC_ETQF_QUEUE_SHIFT)
& IGC_ETQF_QUEUE_MASK);
etqf |= IGC_ETQF_QUEUE_ENABLE;

wr32(IGC_ETQF(i), etqf);

input->etype_reg_index = i;

return 0;
}

static int igc_rxnfc_write_vlan_prio_filter(struct igc_adapter *adapter,
struct igc_nfc_filter *input)
{
struct igc_hw *hw = &adapter->hw;
u8 vlan_priority;
u16 queue_index;
u32 vlapqf;

vlapqf = rd32(IGC_VLAPQF);
vlan_priority = (ntohs(input->filter.vlan_tci) & VLAN_PRIO_MASK)
>> VLAN_PRIO_SHIFT;
queue_index = (vlapqf >> (vlan_priority * 4)) & IGC_VLAPQF_QUEUE_MASK;

/* check whether this vlan prio is already set */
if (vlapqf & IGC_VLAPQF_P_VALID(vlan_priority) &&
queue_index != input->action) {
netdev_err(adapter->netdev,
"ethtool rxnfc set VLAN prio filter failed\n");
return -EEXIST;
}

vlapqf |= IGC_VLAPQF_P_VALID(vlan_priority);
vlapqf |= IGC_VLAPQF_QUEUE_SEL(vlan_priority, input->action);

wr32(IGC_VLAPQF, vlapqf);

return 0;
}

int igc_add_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input)
{
struct igc_hw *hw = &adapter->hw;
Expand All @@ -1263,7 +1199,9 @@ int igc_add_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input)
}

if (input->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) {
err = igc_rxnfc_write_etype_filter(adapter, input);
u16 etype = ntohs(input->filter.etype);

err = igc_add_etype_filter(adapter, etype, input->action);
if (err)
return err;
}
Expand All @@ -1283,53 +1221,30 @@ int igc_add_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input)
return err;
}

if (input->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI)
err = igc_rxnfc_write_vlan_prio_filter(adapter, input);

return err;
}

static void igc_clear_etype_filter_regs(struct igc_adapter *adapter,
u16 reg_index)
{
struct igc_hw *hw = &adapter->hw;
u32 etqf = rd32(IGC_ETQF(reg_index));

etqf &= ~IGC_ETQF_QUEUE_ENABLE;
etqf &= ~IGC_ETQF_QUEUE_MASK;
etqf &= ~IGC_ETQF_FILTER_ENABLE;

wr32(IGC_ETQF(reg_index), etqf);

adapter->etype_bitmap[reg_index] = false;
}

static void igc_clear_vlan_prio_filter(struct igc_adapter *adapter,
u16 vlan_tci)
{
struct igc_hw *hw = &adapter->hw;
u8 vlan_priority;
u32 vlapqf;

vlan_priority = (vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;

vlapqf = rd32(IGC_VLAPQF);
vlapqf &= ~IGC_VLAPQF_P_VALID(vlan_priority);
vlapqf &= ~IGC_VLAPQF_QUEUE_SEL(vlan_priority,
IGC_VLAPQF_QUEUE_MASK);
if (input->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {
int prio = (ntohs(input->filter.vlan_tci) & VLAN_PRIO_MASK) >>
VLAN_PRIO_SHIFT;
err = igc_add_vlan_prio_filter(adapter, prio, input->action);
if (err)
return err;
}

wr32(IGC_VLAPQF, vlapqf);
return 0;
}

int igc_erase_filter(struct igc_adapter *adapter, struct igc_nfc_filter *input)
{
if (input->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE)
igc_clear_etype_filter_regs(adapter,
input->etype_reg_index);
if (input->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) {
u16 etype = ntohs(input->filter.etype);

if (input->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI)
igc_clear_vlan_prio_filter(adapter,
ntohs(input->filter.vlan_tci));
igc_del_etype_filter(adapter, etype);
}

if (input->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {
int prio = (ntohs(input->filter.vlan_tci) & VLAN_PRIO_MASK) >>
VLAN_PRIO_SHIFT;
igc_del_vlan_prio_filter(adapter, prio);
}

if (input->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR)
igc_del_mac_filter(adapter, input->filter.src_addr,
Expand Down Expand Up @@ -1445,7 +1360,8 @@ static int igc_add_ethtool_nfc_entry(struct igc_adapter *adapter,

if ((fsp->flow_type & FLOW_EXT) && fsp->m_ext.vlan_tci) {
if (fsp->m_ext.vlan_tci != htons(VLAN_PRIO_MASK)) {
err = -EINVAL;
netdev_dbg(netdev, "VLAN mask not supported\n");
err = -EOPNOTSUPP;
goto err_out;
}
input->filter.vlan_tci = fsp->h_ext.vlan_tci;
Expand Down
4 changes: 0 additions & 4 deletions drivers/net/ethernet/intel/igc/igc_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
#include "igc_phy.h"
#include "igc_defines.h"

#ifndef IGC_REMOVED
#define IGC_REMOVED(a) (0)
#endif /* IGC_REMOVED */

/* forward declaration */
s32 igc_disable_pcie_master(struct igc_hw *hw);
s32 igc_check_for_copper_link(struct igc_hw *hw);
Expand Down
Loading

0 comments on commit de1b99e

Please sign in to comment.