Skip to content

Commit e0f9956

Browse files
kchuah4davem330
authored andcommitted
net: stmmac: Add option for VLAN filter fail queue enable
Add option in plat_stmmacenet_data struct to enable VLAN Filter Fail Queuing. This option allows packets that fail VLAN filter to be routed to a specific Rx queue when Receive All is also set. When this option is enabled: - Enable VFFQ only when entering promiscuous mode, because Receive All will pass up all rx packets that failed address filtering (similar to promiscuous mode). - VLAN-promiscuous mode is never entered to allow rx packet to fail VLAN filters and get routed to selected VFFQ Rx queue. Reviewed-by: Voon Weifeng <weifeng.voon@intel.com> Reviewed-by: Ong Boon Leong <boon.leong.ong@intel.com> Signed-off-by: Chuah, Kim Tatt <kim.tatt.chuah@intel.com> Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1770543 commit e0f9956

File tree

7 files changed

+32
-2
lines changed

7 files changed

+32
-2
lines changed

drivers/net/ethernet/stmicro/stmmac/common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ struct mac_device_info {
481481
unsigned int num_vlan;
482482
u32 vlan_filter[32];
483483
unsigned int promisc;
484+
bool vlan_fail_q_en;
485+
u8 vlan_fail_q;
484486
};
485487

486488
struct stmmac_rx_routing {

drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
321321
/* Set the maxmtu to a default of JUMBO_LEN */
322322
plat->maxmtu = JUMBO_LEN;
323323

324+
plat->vlan_fail_q_en = true;
325+
326+
/* Use the last Rx queue */
327+
plat->vlan_fail_q = plat->rx_queues_to_use - 1;
328+
324329
return 0;
325330
}
326331

drivers/net/ethernet/stmicro/stmmac/dwmac4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#define GMAC_PACKET_FILTER_HPF BIT(10)
7777
#define GMAC_PACKET_FILTER_VTFE BIT(16)
7878
#define GMAC_PACKET_FILTER_IPFE BIT(20)
79+
#define GMAC_PACKET_FILTER_RA BIT(31)
7980

8081
#define GMAC_MAX_PERFECT_ADDRESSES 128
8182

drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,18 @@ static void dwmac4_set_filter(struct mac_device_info *hw,
618618
value &= ~GMAC_PACKET_FILTER_PM;
619619
value &= ~GMAC_PACKET_FILTER_PR;
620620
if (dev->flags & IFF_PROMISC) {
621-
value = GMAC_PACKET_FILTER_PR | GMAC_PACKET_FILTER_PCF;
621+
/* VLAN Tag Filter Fail Packets Queuing */
622+
if (hw->vlan_fail_q_en) {
623+
value = readl(ioaddr + GMAC_RXQ_CTRL4);
624+
value &= ~GMAC_RXQCTRL_VFFQ_MASK;
625+
value |= GMAC_RXQCTRL_VFFQE |
626+
(hw->vlan_fail_q << GMAC_RXQCTRL_VFFQ_SHIFT);
627+
writel(value, ioaddr + GMAC_RXQ_CTRL4);
628+
value = GMAC_PACKET_FILTER_PR | GMAC_PACKET_FILTER_RA;
629+
} else {
630+
value = GMAC_PACKET_FILTER_PR | GMAC_PACKET_FILTER_PCF;
631+
}
632+
622633
} else if ((dev->flags & IFF_ALLMULTI) ||
623634
(netdev_mc_count(dev) > hw->multicast_filter_bins)) {
624635
/* Pass all multi */
@@ -680,7 +691,7 @@ static void dwmac4_set_filter(struct mac_device_info *hw,
680691

681692
writel(value, ioaddr + GMAC_PACKET_FILTER);
682693

683-
if (dev->flags & IFF_PROMISC) {
694+
if (dev->flags & IFF_PROMISC && !hw->vlan_fail_q_en) {
684695
if (!hw->promisc) {
685696
hw->promisc = 1;
686697
dwmac4_vlan_promisc_enable(dev, hw);

drivers/net/ethernet/stmicro/stmmac/dwmac5.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@
9292
#define TCEIE BIT(0)
9393
#define DMA_ECC_INT_STATUS 0x00001088
9494

95+
/* EQoS version 5.xx VLAN Tag Filter Fail Packets Queuing */
96+
#define GMAC_RXQ_CTRL4 0x00000094
97+
#define GMAC_RXQCTRL_VFFQ_MASK GENMASK(19, 17)
98+
#define GMAC_RXQCTRL_VFFQ_SHIFT 17
99+
#define GMAC_RXQCTRL_VFFQE BIT(16)
100+
95101
int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp);
96102
int dwmac5_safety_feat_irq_status(struct net_device *ndev,
97103
void __iomem *ioaddr, unsigned int asp,

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4713,6 +4713,9 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
47134713
if (priv->dma_cap.tsoen)
47144714
dev_info(priv->device, "TSO supported\n");
47154715

4716+
priv->hw->vlan_fail_q_en = priv->plat->vlan_fail_q_en;
4717+
priv->hw->vlan_fail_q = priv->plat->vlan_fail_q;
4718+
47164719
/* Run HW quirks, if any */
47174720
if (priv->hwif_quirks) {
47184721
ret = priv->hwif_quirks(priv);

include/linux/stmmac.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,5 +198,7 @@ struct plat_stmmacenet_data {
198198
int mac_port_sel_speed;
199199
bool en_tx_lpi_clockgating;
200200
int has_xgmac;
201+
bool vlan_fail_q_en;
202+
u8 vlan_fail_q;
201203
};
202204
#endif

0 commit comments

Comments
 (0)