Commit f5b26503 authored by David S. Miller's avatar David S. Miller

Merge branch 'xgbe-next'

Tom Lendacky says:

====================
amd-xgbe: AMD 10Gb Ethernet driver updates

The following series fixes some bugs and provides new/changed support
in the driver.

- Make all the defines in the xgbe.h file unique by prefixing them with
  XGBE_ if they are not currently using the prefix.
- VLAN CTAGs are supplied in context descriptors. Tell the hardware to
  look in the Tx context descriptor, and not a register, for the VLAN CTAG
  to be inserted in the packet.
- The hardware will indicate a VLAN packet has been received even if VLAN
  CTAG stripping is currently disabled.  Only indicate that a VLAN CTAG
  has been stripped for the current packet if stripping is enabled.
- Add support for VLAN filtering
- Modify destination address filtering to use the hardware hash tables
- Eliminate a checkpatch warning by replacing sscanf with kstrtouint

This patch series is based on net-next.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 9b8d90b9 66f95c35
...@@ -182,6 +182,8 @@ config AMD_XGBE ...@@ -182,6 +182,8 @@ config AMD_XGBE
depends on OF_NET depends on OF_NET
select PHYLIB select PHYLIB
select AMD_XGBE_PHY select AMD_XGBE_PHY
select BITREVERSE
select CRC32
---help--- ---help---
This driver supports the AMD 10GbE Ethernet device found on an This driver supports the AMD 10GbE Ethernet device found on an
AMD SoC. AMD SoC.
......
...@@ -276,13 +276,6 @@ ...@@ -276,13 +276,6 @@
#define MAC_PFR 0x0008 #define MAC_PFR 0x0008
#define MAC_WTR 0x000c #define MAC_WTR 0x000c
#define MAC_HTR0 0x0010 #define MAC_HTR0 0x0010
#define MAC_HTR1 0x0014
#define MAC_HTR2 0x0018
#define MAC_HTR3 0x001c
#define MAC_HTR4 0x0020
#define MAC_HTR5 0x0024
#define MAC_HTR6 0x0028
#define MAC_HTR7 0x002c
#define MAC_VLANTR 0x0050 #define MAC_VLANTR 0x0050
#define MAC_VLANHTR 0x0058 #define MAC_VLANHTR 0x0058
#define MAC_VLANIR 0x0060 #define MAC_VLANIR 0x0060
...@@ -315,6 +308,7 @@ ...@@ -315,6 +308,7 @@
#define MAC_QTFCR_INC 4 #define MAC_QTFCR_INC 4
#define MAC_MACA_INC 4 #define MAC_MACA_INC 4
#define MAC_HTR_INC 4
/* MAC register entry bit positions and sizes */ /* MAC register entry bit positions and sizes */
#define MAC_HWF0R_ADDMACADRSEL_INDEX 18 #define MAC_HWF0R_ADDMACADRSEL_INDEX 18
...@@ -387,12 +381,16 @@ ...@@ -387,12 +381,16 @@
#define MAC_MACA1HR_AE_WIDTH 1 #define MAC_MACA1HR_AE_WIDTH 1
#define MAC_PFR_HMC_INDEX 2 #define MAC_PFR_HMC_INDEX 2
#define MAC_PFR_HMC_WIDTH 1 #define MAC_PFR_HMC_WIDTH 1
#define MAC_PFR_HPF_INDEX 10
#define MAC_PFR_HPF_WIDTH 1
#define MAC_PFR_HUC_INDEX 1 #define MAC_PFR_HUC_INDEX 1
#define MAC_PFR_HUC_WIDTH 1 #define MAC_PFR_HUC_WIDTH 1
#define MAC_PFR_PM_INDEX 4 #define MAC_PFR_PM_INDEX 4
#define MAC_PFR_PM_WIDTH 1 #define MAC_PFR_PM_WIDTH 1
#define MAC_PFR_PR_INDEX 0 #define MAC_PFR_PR_INDEX 0
#define MAC_PFR_PR_WIDTH 1 #define MAC_PFR_PR_WIDTH 1
#define MAC_PFR_VTFE_INDEX 16
#define MAC_PFR_VTFE_WIDTH 1
#define MAC_PMTCSR_MGKPKTEN_INDEX 1 #define MAC_PMTCSR_MGKPKTEN_INDEX 1
#define MAC_PMTCSR_MGKPKTEN_WIDTH 1 #define MAC_PMTCSR_MGKPKTEN_WIDTH 1
#define MAC_PMTCSR_PWRDWN_INDEX 0 #define MAC_PMTCSR_PWRDWN_INDEX 0
...@@ -427,16 +425,30 @@ ...@@ -427,16 +425,30 @@
#define MAC_TCR_SS_WIDTH 2 #define MAC_TCR_SS_WIDTH 2
#define MAC_TCR_TE_INDEX 0 #define MAC_TCR_TE_INDEX 0
#define MAC_TCR_TE_WIDTH 1 #define MAC_TCR_TE_WIDTH 1
#define MAC_VLANHTR_VLHT_INDEX 0
#define MAC_VLANHTR_VLHT_WIDTH 16
#define MAC_VLANIR_VLTI_INDEX 20
#define MAC_VLANIR_VLTI_WIDTH 1
#define MAC_VLANIR_CSVL_INDEX 19
#define MAC_VLANIR_CSVL_WIDTH 1
#define MAC_VLANTR_DOVLTC_INDEX 20 #define MAC_VLANTR_DOVLTC_INDEX 20
#define MAC_VLANTR_DOVLTC_WIDTH 1 #define MAC_VLANTR_DOVLTC_WIDTH 1
#define MAC_VLANTR_ERSVLM_INDEX 19 #define MAC_VLANTR_ERSVLM_INDEX 19
#define MAC_VLANTR_ERSVLM_WIDTH 1 #define MAC_VLANTR_ERSVLM_WIDTH 1
#define MAC_VLANTR_ESVL_INDEX 18 #define MAC_VLANTR_ESVL_INDEX 18
#define MAC_VLANTR_ESVL_WIDTH 1 #define MAC_VLANTR_ESVL_WIDTH 1
#define MAC_VLANTR_ETV_INDEX 16
#define MAC_VLANTR_ETV_WIDTH 1
#define MAC_VLANTR_EVLS_INDEX 21 #define MAC_VLANTR_EVLS_INDEX 21
#define MAC_VLANTR_EVLS_WIDTH 2 #define MAC_VLANTR_EVLS_WIDTH 2
#define MAC_VLANTR_EVLRXS_INDEX 24 #define MAC_VLANTR_EVLRXS_INDEX 24
#define MAC_VLANTR_EVLRXS_WIDTH 1 #define MAC_VLANTR_EVLRXS_WIDTH 1
#define MAC_VLANTR_VL_INDEX 0
#define MAC_VLANTR_VL_WIDTH 16
#define MAC_VLANTR_VTHM_INDEX 25
#define MAC_VLANTR_VTHM_WIDTH 1
#define MAC_VLANTR_VTIM_INDEX 17
#define MAC_VLANTR_VTIM_WIDTH 1
#define MAC_VR_DEVID_INDEX 8 #define MAC_VR_DEVID_INDEX 8
#define MAC_VR_DEVID_WIDTH 8 #define MAC_VR_DEVID_WIDTH 8
#define MAC_VR_SNPSVER_INDEX 0 #define MAC_VR_SNPSVER_INDEX 0
......
...@@ -151,7 +151,7 @@ static ssize_t xgbe_common_write(const char __user *buffer, size_t count, ...@@ -151,7 +151,7 @@ static ssize_t xgbe_common_write(const char __user *buffer, size_t count,
{ {
char workarea[32]; char workarea[32];
ssize_t len; ssize_t len;
unsigned int scan_value; int ret;
if (*ppos != 0) if (*ppos != 0)
return 0; return 0;
...@@ -165,10 +165,9 @@ static ssize_t xgbe_common_write(const char __user *buffer, size_t count, ...@@ -165,10 +165,9 @@ static ssize_t xgbe_common_write(const char __user *buffer, size_t count,
return len; return len;
workarea[len] = '\0'; workarea[len] = '\0';
if (sscanf(workarea, "%x", &scan_value) == 1) ret = kstrtouint(workarea, 0, value);
*value = scan_value; if (ret)
else return ret;
return -EIO;
return len; return len;
} }
......
...@@ -131,7 +131,7 @@ static void xgbe_free_ring(struct xgbe_prv_data *pdata, ...@@ -131,7 +131,7 @@ static void xgbe_free_ring(struct xgbe_prv_data *pdata,
if (ring->rdata) { if (ring->rdata) {
for (i = 0; i < ring->rdesc_count; i++) { for (i = 0; i < ring->rdesc_count; i++) {
rdata = GET_DESC_DATA(ring, i); rdata = XGBE_GET_DESC_DATA(ring, i);
xgbe_unmap_skb(pdata, rdata); xgbe_unmap_skb(pdata, rdata);
} }
...@@ -256,7 +256,7 @@ static void xgbe_wrapper_tx_descriptor_init(struct xgbe_prv_data *pdata) ...@@ -256,7 +256,7 @@ static void xgbe_wrapper_tx_descriptor_init(struct xgbe_prv_data *pdata)
rdesc_dma = ring->rdesc_dma; rdesc_dma = ring->rdesc_dma;
for (j = 0; j < ring->rdesc_count; j++) { for (j = 0; j < ring->rdesc_count; j++) {
rdata = GET_DESC_DATA(ring, j); rdata = XGBE_GET_DESC_DATA(ring, j);
rdata->rdesc = rdesc; rdata->rdesc = rdesc;
rdata->rdesc_dma = rdesc_dma; rdata->rdesc_dma = rdesc_dma;
...@@ -298,7 +298,7 @@ static void xgbe_wrapper_rx_descriptor_init(struct xgbe_prv_data *pdata) ...@@ -298,7 +298,7 @@ static void xgbe_wrapper_rx_descriptor_init(struct xgbe_prv_data *pdata)
rdesc_dma = ring->rdesc_dma; rdesc_dma = ring->rdesc_dma;
for (j = 0; j < ring->rdesc_count; j++) { for (j = 0; j < ring->rdesc_count; j++) {
rdata = GET_DESC_DATA(ring, j); rdata = XGBE_GET_DESC_DATA(ring, j);
rdata->rdesc = rdesc; rdata->rdesc = rdesc;
rdata->rdesc_dma = rdesc_dma; rdata->rdesc_dma = rdesc_dma;
...@@ -392,7 +392,7 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb) ...@@ -392,7 +392,7 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb)
if ((tso && (packet->mss != ring->tx.cur_mss)) || if ((tso && (packet->mss != ring->tx.cur_mss)) ||
(vlan && (packet->vlan_ctag != ring->tx.cur_vlan_ctag))) (vlan && (packet->vlan_ctag != ring->tx.cur_vlan_ctag)))
cur_index++; cur_index++;
rdata = GET_DESC_DATA(ring, cur_index); rdata = XGBE_GET_DESC_DATA(ring, cur_index);
if (tso) { if (tso) {
DBGPR(" TSO packet\n"); DBGPR(" TSO packet\n");
...@@ -413,12 +413,12 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb) ...@@ -413,12 +413,12 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb)
packet->length += packet->header_len; packet->length += packet->header_len;
cur_index++; cur_index++;
rdata = GET_DESC_DATA(ring, cur_index); rdata = XGBE_GET_DESC_DATA(ring, cur_index);
} }
/* Map the (remainder of the) packet */ /* Map the (remainder of the) packet */
for (datalen = skb_headlen(skb) - offset; datalen; ) { for (datalen = skb_headlen(skb) - offset; datalen; ) {
len = min_t(unsigned int, datalen, TX_MAX_BUF_SIZE); len = min_t(unsigned int, datalen, XGBE_TX_MAX_BUF_SIZE);
skb_dma = dma_map_single(pdata->dev, skb->data + offset, len, skb_dma = dma_map_single(pdata->dev, skb->data + offset, len,
DMA_TO_DEVICE); DMA_TO_DEVICE);
...@@ -437,7 +437,7 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb) ...@@ -437,7 +437,7 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb)
packet->length += len; packet->length += len;
cur_index++; cur_index++;
rdata = GET_DESC_DATA(ring, cur_index); rdata = XGBE_GET_DESC_DATA(ring, cur_index);
} }
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
...@@ -447,7 +447,8 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb) ...@@ -447,7 +447,8 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb)
offset = 0; offset = 0;
for (datalen = skb_frag_size(frag); datalen; ) { for (datalen = skb_frag_size(frag); datalen; ) {
len = min_t(unsigned int, datalen, TX_MAX_BUF_SIZE); len = min_t(unsigned int, datalen,
XGBE_TX_MAX_BUF_SIZE);
skb_dma = skb_frag_dma_map(pdata->dev, frag, offset, skb_dma = skb_frag_dma_map(pdata->dev, frag, offset,
len, DMA_TO_DEVICE); len, DMA_TO_DEVICE);
...@@ -468,7 +469,7 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb) ...@@ -468,7 +469,7 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb)
packet->length += len; packet->length += len;
cur_index++; cur_index++;
rdata = GET_DESC_DATA(ring, cur_index); rdata = XGBE_GET_DESC_DATA(ring, cur_index);
} }
} }
...@@ -484,7 +485,7 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb) ...@@ -484,7 +485,7 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb)
err_out: err_out:
while (start_index < cur_index) { while (start_index < cur_index) {
rdata = GET_DESC_DATA(ring, start_index++); rdata = XGBE_GET_DESC_DATA(ring, start_index++);
xgbe_unmap_skb(pdata, rdata); xgbe_unmap_skb(pdata, rdata);
} }
...@@ -507,7 +508,7 @@ static void xgbe_realloc_skb(struct xgbe_channel *channel) ...@@ -507,7 +508,7 @@ static void xgbe_realloc_skb(struct xgbe_channel *channel)
ring->rx.realloc_index); ring->rx.realloc_index);
for (i = 0; i < ring->dirty; i++) { for (i = 0; i < ring->dirty; i++) {
rdata = GET_DESC_DATA(ring, ring->rx.realloc_index); rdata = XGBE_GET_DESC_DATA(ring, ring->rx.realloc_index);
/* Reset rdata values */ /* Reset rdata values */
xgbe_unmap_skb(pdata, rdata); xgbe_unmap_skb(pdata, rdata);
......
This diff is collapsed.
...@@ -144,9 +144,10 @@ static int xgbe_calc_rx_buf_size(struct net_device *netdev, unsigned int mtu) ...@@ -144,9 +144,10 @@ static int xgbe_calc_rx_buf_size(struct net_device *netdev, unsigned int mtu)
} }
rx_buf_size = mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN; rx_buf_size = mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
if (rx_buf_size < RX_MIN_BUF_SIZE) if (rx_buf_size < XGBE_RX_MIN_BUF_SIZE)
rx_buf_size = RX_MIN_BUF_SIZE; rx_buf_size = XGBE_RX_MIN_BUF_SIZE;
rx_buf_size = (rx_buf_size + RX_BUF_ALIGN - 1) & ~(RX_BUF_ALIGN - 1); rx_buf_size = (rx_buf_size + XGBE_RX_BUF_ALIGN - 1) &
~(XGBE_RX_BUF_ALIGN - 1);
return rx_buf_size; return rx_buf_size;
} }
...@@ -377,6 +378,21 @@ void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata) ...@@ -377,6 +378,21 @@ void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata)
hw_feat->pps_out_num = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, PPSOUTNUM); hw_feat->pps_out_num = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, PPSOUTNUM);
hw_feat->aux_snap_num = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, AUXSNAPNUM); hw_feat->aux_snap_num = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, AUXSNAPNUM);
/* Translate the Hash Table size into actual number */
switch (hw_feat->hash_table_size) {
case 0:
break;
case 1:
hw_feat->hash_table_size = 64;
break;
case 2:
hw_feat->hash_table_size = 128;
break;
case 3:
hw_feat->hash_table_size = 256;
break;
}
/* The Queue and Channel counts are zero based so increment them /* The Queue and Channel counts are zero based so increment them
* to get the actual number * to get the actual number
*/ */
...@@ -446,7 +462,7 @@ static void xgbe_free_tx_skbuff(struct xgbe_prv_data *pdata) ...@@ -446,7 +462,7 @@ static void xgbe_free_tx_skbuff(struct xgbe_prv_data *pdata)
break; break;
for (j = 0; j < ring->rdesc_count; j++) { for (j = 0; j < ring->rdesc_count; j++) {
rdata = GET_DESC_DATA(ring, j); rdata = XGBE_GET_DESC_DATA(ring, j);
desc_if->unmap_skb(pdata, rdata); desc_if->unmap_skb(pdata, rdata);
} }
} }
...@@ -471,7 +487,7 @@ static void xgbe_free_rx_skbuff(struct xgbe_prv_data *pdata) ...@@ -471,7 +487,7 @@ static void xgbe_free_rx_skbuff(struct xgbe_prv_data *pdata)
break; break;
for (j = 0; j < ring->rdesc_count; j++) { for (j = 0; j < ring->rdesc_count; j++) {
rdata = GET_DESC_DATA(ring, j); rdata = XGBE_GET_DESC_DATA(ring, j);
desc_if->unmap_skb(pdata, rdata); desc_if->unmap_skb(pdata, rdata);
} }
} }
...@@ -726,14 +742,14 @@ static void xgbe_packet_info(struct xgbe_ring *ring, struct sk_buff *skb, ...@@ -726,14 +742,14 @@ static void xgbe_packet_info(struct xgbe_ring *ring, struct sk_buff *skb,
for (len = skb_headlen(skb); len;) { for (len = skb_headlen(skb); len;) {
packet->rdesc_count++; packet->rdesc_count++;
len -= min_t(unsigned int, len, TX_MAX_BUF_SIZE); len -= min_t(unsigned int, len, XGBE_TX_MAX_BUF_SIZE);
} }
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
frag = &skb_shinfo(skb)->frags[i]; frag = &skb_shinfo(skb)->frags[i];
for (len = skb_frag_size(frag); len; ) { for (len = skb_frag_size(frag); len; ) {
packet->rdesc_count++; packet->rdesc_count++;
len -= min_t(unsigned int, len, TX_MAX_BUF_SIZE); len -= min_t(unsigned int, len, XGBE_TX_MAX_BUF_SIZE);
} }
} }
} }
...@@ -911,18 +927,10 @@ static void xgbe_set_rx_mode(struct net_device *netdev) ...@@ -911,18 +927,10 @@ static void xgbe_set_rx_mode(struct net_device *netdev)
pr_mode = ((netdev->flags & IFF_PROMISC) != 0); pr_mode = ((netdev->flags & IFF_PROMISC) != 0);
am_mode = ((netdev->flags & IFF_ALLMULTI) != 0); am_mode = ((netdev->flags & IFF_ALLMULTI) != 0);
if (netdev_uc_count(netdev) > pdata->hw_feat.addn_mac)
pr_mode = 1;
if (netdev_mc_count(netdev) > pdata->hw_feat.addn_mac)
am_mode = 1;
if ((netdev_uc_count(netdev) + netdev_mc_count(netdev)) >
pdata->hw_feat.addn_mac)
pr_mode = 1;
hw_if->set_promiscuous_mode(pdata, pr_mode); hw_if->set_promiscuous_mode(pdata, pr_mode);
hw_if->set_all_multicast_mode(pdata, am_mode); hw_if->set_all_multicast_mode(pdata, am_mode);
if (!pr_mode)
hw_if->set_addn_mac_addrs(pdata, am_mode); hw_if->add_mac_addresses(pdata);
DBGPR("<--xgbe_set_rx_mode\n"); DBGPR("<--xgbe_set_rx_mode\n");
} }
...@@ -999,6 +1007,38 @@ static struct rtnl_link_stats64 *xgbe_get_stats64(struct net_device *netdev, ...@@ -999,6 +1007,38 @@ static struct rtnl_link_stats64 *xgbe_get_stats64(struct net_device *netdev,
return s; return s;
} }
static int xgbe_vlan_rx_add_vid(struct net_device *netdev, __be16 proto,
u16 vid)
{
struct xgbe_prv_data *pdata = netdev_priv(netdev);
struct xgbe_hw_if *hw_if = &pdata->hw_if;
DBGPR("-->%s\n", __func__);
set_bit(vid, pdata->active_vlans);
hw_if->update_vlan_hash_table(pdata);
DBGPR("<--%s\n", __func__);
return 0;
}
static int xgbe_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto,
u16 vid)
{
struct xgbe_prv_data *pdata = netdev_priv(netdev);
struct xgbe_hw_if *hw_if = &pdata->hw_if;
DBGPR("-->%s\n", __func__);
clear_bit(vid, pdata->active_vlans);
hw_if->update_vlan_hash_table(pdata);
DBGPR("<--%s\n", __func__);
return 0;
}
#ifdef CONFIG_NET_POLL_CONTROLLER #ifdef CONFIG_NET_POLL_CONTROLLER
static void xgbe_poll_controller(struct net_device *netdev) static void xgbe_poll_controller(struct net_device *netdev)
{ {
...@@ -1021,26 +1061,26 @@ static int xgbe_set_features(struct net_device *netdev, ...@@ -1021,26 +1061,26 @@ static int xgbe_set_features(struct net_device *netdev,
{ {
struct xgbe_prv_data *pdata = netdev_priv(netdev); struct xgbe_prv_data *pdata = netdev_priv(netdev);
struct xgbe_hw_if *hw_if = &pdata->hw_if; struct xgbe_hw_if *hw_if = &pdata->hw_if;
unsigned int rxcsum_enabled, rxvlan_enabled; unsigned int rxcsum, rxvlan, rxvlan_filter;
rxcsum_enabled = !!(pdata->netdev_features & NETIF_F_RXCSUM); rxcsum = pdata->netdev_features & NETIF_F_RXCSUM;
rxvlan_enabled = !!(pdata->netdev_features & NETIF_F_HW_VLAN_CTAG_RX); rxvlan = pdata->netdev_features & NETIF_F_HW_VLAN_CTAG_RX;
rxvlan_filter = pdata->netdev_features & NETIF_F_HW_VLAN_CTAG_FILTER;
if ((features & NETIF_F_RXCSUM) && !rxcsum_enabled) { if ((features & NETIF_F_RXCSUM) && !rxcsum)
hw_if->enable_rx_csum(pdata); hw_if->enable_rx_csum(pdata);
netdev_alert(netdev, "state change - rxcsum enabled\n"); else if (!(features & NETIF_F_RXCSUM) && rxcsum)
} else if (!(features & NETIF_F_RXCSUM) && rxcsum_enabled) {
hw_if->disable_rx_csum(pdata); hw_if->disable_rx_csum(pdata);
netdev_alert(netdev, "state change - rxcsum disabled\n");
}
if ((features & NETIF_F_HW_VLAN_CTAG_RX) && !rxvlan_enabled) { if ((features & NETIF_F_HW_VLAN_CTAG_RX) && !rxvlan)
hw_if->enable_rx_vlan_stripping(pdata); hw_if->enable_rx_vlan_stripping(pdata);
netdev_alert(netdev, "state change - rxvlan enabled\n"); else if (!(features & NETIF_F_HW_VLAN_CTAG_RX) && rxvlan)
} else if (!(features & NETIF_F_HW_VLAN_CTAG_RX) && rxvlan_enabled) {
hw_if->disable_rx_vlan_stripping(pdata); hw_if->disable_rx_vlan_stripping(pdata);
netdev_alert(netdev, "state change - rxvlan disabled\n");
} if ((features & NETIF_F_HW_VLAN_CTAG_FILTER) && !rxvlan_filter)
hw_if->enable_rx_vlan_filtering(pdata);
else if (!(features & NETIF_F_HW_VLAN_CTAG_FILTER) && rxvlan_filter)
hw_if->disable_rx_vlan_filtering(pdata);
pdata->netdev_features = features; pdata->netdev_features = features;
...@@ -1058,6 +1098,8 @@ static const struct net_device_ops xgbe_netdev_ops = { ...@@ -1058,6 +1098,8 @@ static const struct net_device_ops xgbe_netdev_ops = {
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
.ndo_change_mtu = xgbe_change_mtu, .ndo_change_mtu = xgbe_change_mtu,
.ndo_get_stats64 = xgbe_get_stats64, .ndo_get_stats64 = xgbe_get_stats64,
.ndo_vlan_rx_add_vid = xgbe_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = xgbe_vlan_rx_kill_vid,
#ifdef CONFIG_NET_POLL_CONTROLLER #ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = xgbe_poll_controller, .ndo_poll_controller = xgbe_poll_controller,
#endif #endif
...@@ -1089,8 +1131,9 @@ static int xgbe_tx_poll(struct xgbe_channel *channel) ...@@ -1089,8 +1131,9 @@ static int xgbe_tx_poll(struct xgbe_channel *channel)
spin_lock_irqsave(&ring->lock, flags); spin_lock_irqsave(&ring->lock, flags);
while ((processed < TX_DESC_MAX_PROC) && (ring->dirty < ring->cur)) { while ((processed < XGBE_TX_DESC_MAX_PROC) &&
rdata = GET_DESC_DATA(ring, ring->dirty); (ring->dirty < ring->cur)) {
rdata = XGBE_GET_DESC_DATA(ring, ring->dirty);
rdesc = rdata->rdesc; rdesc = rdata->rdesc;
if (!hw_if->tx_complete(rdesc)) if (!hw_if->tx_complete(rdesc))
...@@ -1109,7 +1152,7 @@ static int xgbe_tx_poll(struct xgbe_channel *channel) ...@@ -1109,7 +1152,7 @@ static int xgbe_tx_poll(struct xgbe_channel *channel)
} }
if ((ring->tx.queue_stopped == 1) && if ((ring->tx.queue_stopped == 1) &&
(xgbe_tx_avail_desc(ring) > TX_DESC_MIN_FREE)) { (xgbe_tx_avail_desc(ring) > XGBE_TX_DESC_MIN_FREE)) {
ring->tx.queue_stopped = 0; ring->tx.queue_stopped = 0;
netif_wake_subqueue(netdev, channel->queue_index); netif_wake_subqueue(netdev, channel->queue_index);
} }
...@@ -1152,7 +1195,7 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget) ...@@ -1152,7 +1195,7 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
cur_len = 0; cur_len = 0;
read_again: read_again:
rdata = GET_DESC_DATA(ring, ring->cur); rdata = XGBE_GET_DESC_DATA(ring, ring->cur);
if (hw_if->dev_read(channel)) if (hw_if->dev_read(channel))
break; break;
...@@ -1244,7 +1287,7 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget) ...@@ -1244,7 +1287,7 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
/* Update the Rx Tail Pointer Register with address of /* Update the Rx Tail Pointer Register with address of
* the last cleaned entry */ * the last cleaned entry */
rdata = GET_DESC_DATA(ring, ring->rx.realloc_index - 1); rdata = XGBE_GET_DESC_DATA(ring, ring->rx.realloc_index - 1);
XGMAC_DMA_IOWRITE(channel, DMA_CH_RDTR_LO, XGMAC_DMA_IOWRITE(channel, DMA_CH_RDTR_LO,
lower_32_bits(rdata->rdesc_dma)); lower_32_bits(rdata->rdesc_dma));
} }
...@@ -1296,7 +1339,7 @@ void xgbe_dump_tx_desc(struct xgbe_ring *ring, unsigned int idx, ...@@ -1296,7 +1339,7 @@ void xgbe_dump_tx_desc(struct xgbe_ring *ring, unsigned int idx,
struct xgbe_ring_desc *rdesc; struct xgbe_ring_desc *rdesc;
while (count--) { while (count--) {
rdata = GET_DESC_DATA(ring, idx); rdata = XGBE_GET_DESC_DATA(ring, idx);
rdesc = rdata->rdesc; rdesc = rdata->rdesc;
DBGPR("TX_NORMAL_DESC[%d %s] = %08x:%08x:%08x:%08x\n", idx, DBGPR("TX_NORMAL_DESC[%d %s] = %08x:%08x:%08x:%08x\n", idx,
(flag == 1) ? "QUEUED FOR TX" : "TX BY DEVICE", (flag == 1) ? "QUEUED FOR TX" : "TX BY DEVICE",
......
...@@ -247,16 +247,16 @@ static int xgbe_probe(struct platform_device *pdev) ...@@ -247,16 +247,16 @@ static int xgbe_probe(struct platform_device *pdev)
mutex_init(&pdata->xpcs_mutex); mutex_init(&pdata->xpcs_mutex);
/* Set and validate the number of descriptors for a ring */ /* Set and validate the number of descriptors for a ring */
BUILD_BUG_ON_NOT_POWER_OF_2(TX_DESC_CNT); BUILD_BUG_ON_NOT_POWER_OF_2(XGBE_TX_DESC_CNT);
pdata->tx_desc_count = TX_DESC_CNT; pdata->tx_desc_count = XGBE_TX_DESC_CNT;
if (pdata->tx_desc_count & (pdata->tx_desc_count - 1)) { if (pdata->tx_desc_count & (pdata->tx_desc_count - 1)) {
dev_err(dev, "tx descriptor count (%d) is not valid\n", dev_err(dev, "tx descriptor count (%d) is not valid\n",
pdata->tx_desc_count); pdata->tx_desc_count);
ret = -EINVAL; ret = -EINVAL;
goto err_io; goto err_io;
} }
BUILD_BUG_ON_NOT_POWER_OF_2(RX_DESC_CNT); BUILD_BUG_ON_NOT_POWER_OF_2(XGBE_RX_DESC_CNT);
pdata->rx_desc_count = RX_DESC_CNT; pdata->rx_desc_count = XGBE_RX_DESC_CNT;
if (pdata->rx_desc_count & (pdata->rx_desc_count - 1)) { if (pdata->rx_desc_count & (pdata->rx_desc_count - 1)) {
dev_err(dev, "rx descriptor count (%d) is not valid\n", dev_err(dev, "rx descriptor count (%d) is not valid\n",
pdata->rx_desc_count); pdata->rx_desc_count);
...@@ -385,7 +385,8 @@ static int xgbe_probe(struct platform_device *pdev) ...@@ -385,7 +385,8 @@ static int xgbe_probe(struct platform_device *pdev)
NETIF_F_TSO6 | NETIF_F_TSO6 |
NETIF_F_GRO | NETIF_F_GRO |
NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_RX |
NETIF_F_HW_VLAN_CTAG_TX; NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_CTAG_FILTER;
netdev->vlan_features |= NETIF_F_SG | netdev->vlan_features |= NETIF_F_SG |
NETIF_F_IP_CSUM | NETIF_F_IP_CSUM |
...@@ -396,6 +397,8 @@ static int xgbe_probe(struct platform_device *pdev) ...@@ -396,6 +397,8 @@ static int xgbe_probe(struct platform_device *pdev)
netdev->features |= netdev->hw_features; netdev->features |= netdev->hw_features;
pdata->netdev_features = netdev->features; pdata->netdev_features = netdev->features;
netdev->priv_flags |= IFF_UNICAST_FLT;
xgbe_init_rx_coalesce(pdata); xgbe_init_rx_coalesce(pdata);
xgbe_init_tx_coalesce(pdata); xgbe_init_tx_coalesce(pdata);
......
...@@ -121,6 +121,8 @@ ...@@ -121,6 +121,8 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/if_vlan.h>
#include <linux/bitops.h>
#define XGBE_DRV_NAME "amd-xgbe" #define XGBE_DRV_NAME "amd-xgbe"
...@@ -128,22 +130,25 @@ ...@@ -128,22 +130,25 @@
#define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver" #define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver"
/* Descriptor related defines */ /* Descriptor related defines */
#define TX_DESC_CNT 512 #define XGBE_TX_DESC_CNT 512
#define TX_DESC_MIN_FREE (TX_DESC_CNT >> 3) #define XGBE_TX_DESC_MIN_FREE (XGBE_TX_DESC_CNT >> 3)
#define TX_DESC_MAX_PROC (TX_DESC_CNT >> 1) #define XGBE_TX_DESC_MAX_PROC (XGBE_TX_DESC_CNT >> 1)
#define RX_DESC_CNT 512 #define XGBE_RX_DESC_CNT 512
#define TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1)) #define XGBE_TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1))
#define RX_MIN_BUF_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN) #define XGBE_RX_MIN_BUF_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
#define RX_BUF_ALIGN 64 #define XGBE_RX_BUF_ALIGN 64
#define XGBE_MAX_DMA_CHANNELS 16 #define XGBE_MAX_DMA_CHANNELS 16
#define DMA_ARDOMAIN_SETTING 0x2
#define DMA_ARCACHE_SETTING 0xb /* DMA cache settings - Outer sharable, write-back, write-allocate */
#define DMA_AWDOMAIN_SETTING 0x2 #define XGBE_DMA_ARDOMAIN 0x2
#define DMA_AWCACHE_SETTING 0x7 #define XGBE_DMA_ARCACHE 0xb
#define DMA_INTERRUPT_MASK 0x31c7 #define XGBE_DMA_AWDOMAIN 0x2
#define XGBE_DMA_AWCACHE 0x7
#define XGBE_DMA_INTERRUPT_MASK 0x31c7
#define XGMAC_MIN_PACKET 60 #define XGMAC_MIN_PACKET 60
#define XGMAC_STD_PACKET_MTU 1500 #define XGMAC_STD_PACKET_MTU 1500
...@@ -151,10 +156,6 @@ ...@@ -151,10 +156,6 @@
#define XGMAC_JUMBO_PACKET_MTU 9000 #define XGMAC_JUMBO_PACKET_MTU 9000
#define XGMAC_MAX_JUMBO_PACKET 9018 #define XGMAC_MAX_JUMBO_PACKET 9018
#define MAX_MULTICAST_LIST 14
#define TX_FLAGS_IP_PKT 0x00000001
#define TX_FLAGS_TCP_PKT 0x00000002
/* MDIO bus phy name */ /* MDIO bus phy name */
#define XGBE_PHY_NAME "amd_xgbe_phy" #define XGBE_PHY_NAME "amd_xgbe_phy"
#define XGBE_PRTAD 0 #define XGBE_PRTAD 0
...@@ -163,18 +164,18 @@ ...@@ -163,18 +164,18 @@
#define XGMAC_DRIVER_CONTEXT 1 #define XGMAC_DRIVER_CONTEXT 1
#define XGMAC_IOCTL_CONTEXT 2 #define XGMAC_IOCTL_CONTEXT 2
#define FIFO_SIZE_B(x) (x) #define XGBE_FIFO_SIZE_B(x) (x)
#define FIFO_SIZE_KB(x) (x * 1024) #define XGBE_FIFO_SIZE_KB(x) (x * 1024)
#define XGBE_TC_CNT 2 #define XGBE_TC_CNT 2
/* Helper macro for descriptor handling /* Helper macro for descriptor handling
* Always use GET_DESC_DATA to access the descriptor data * Always use XGBE_GET_DESC_DATA to access the descriptor data
* since the index is free-running and needs to be and-ed * since the index is free-running and needs to be and-ed
* with the descriptor count value of the ring to index to * with the descriptor count value of the ring to index to
* the proper descriptor data. * the proper descriptor data.
*/ */
#define GET_DESC_DATA(_ring, _idx) \ #define XGBE_GET_DESC_DATA(_ring, _idx) \
((_ring)->rdata + \ ((_ring)->rdata + \
((_idx) & ((_ring)->rdesc_count - 1))) ((_idx) & ((_ring)->rdesc_count - 1)))
...@@ -190,6 +191,8 @@ ...@@ -190,6 +191,8 @@
/* Flow control queue count */ /* Flow control queue count */
#define XGMAC_MAX_FLOW_CONTROL_QUEUES 8 #define XGMAC_MAX_FLOW_CONTROL_QUEUES 8
/* Maximum MAC address hash table size (256 bits = 8 bytes) */
#define XGBE_MAC_HASH_TABLE_SIZE 8
struct xgbe_prv_data; struct xgbe_prv_data;
...@@ -219,7 +222,7 @@ struct xgbe_ring_desc { ...@@ -219,7 +222,7 @@ struct xgbe_ring_desc {
/* Structure used to hold information related to the descriptor /* Structure used to hold information related to the descriptor
* and the packet associated with the descriptor (always use * and the packet associated with the descriptor (always use
* use the GET_DESC_DATA macro to access this data from the ring) * use the XGBE_GET_DESC_DATA macro to access this data from the ring)
*/ */
struct xgbe_ring_data { struct xgbe_ring_data {
struct xgbe_ring_desc *rdesc; /* Virtual address of descriptor */ struct xgbe_ring_desc *rdesc; /* Virtual address of descriptor */
...@@ -250,7 +253,7 @@ struct xgbe_ring { ...@@ -250,7 +253,7 @@ struct xgbe_ring {
unsigned int rdesc_count; unsigned int rdesc_count;
/* Array of descriptor data corresponding the descriptor memory /* Array of descriptor data corresponding the descriptor memory
* (always use the GET_DESC_DATA macro to access this data) * (always use the XGBE_GET_DESC_DATA macro to access this data)
*/ */
struct xgbe_ring_data *rdata; struct xgbe_ring_data *rdata;
...@@ -386,7 +389,7 @@ struct xgbe_hw_if { ...@@ -386,7 +389,7 @@ struct xgbe_hw_if {
int (*set_promiscuous_mode)(struct xgbe_prv_data *, unsigned int); int (*set_promiscuous_mode)(struct xgbe_prv_data *, unsigned int);
int (*set_all_multicast_mode)(struct xgbe_prv_data *, unsigned int); int (*set_all_multicast_mode)(struct xgbe_prv_data *, unsigned int);
int (*set_addn_mac_addrs)(struct xgbe_prv_data *, unsigned int); int (*add_mac_addresses)(struct xgbe_prv_data *);
int (*set_mac_address)(struct xgbe_prv_data *, u8 *addr); int (*set_mac_address)(struct xgbe_prv_data *, u8 *addr);
int (*enable_rx_csum)(struct xgbe_prv_data *); int (*enable_rx_csum)(struct xgbe_prv_data *);
...@@ -394,6 +397,9 @@ struct xgbe_hw_if { ...@@ -394,6 +397,9 @@ struct xgbe_hw_if {
int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *); int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *);
int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *); int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *);
int (*enable_rx_vlan_filtering)(struct xgbe_prv_data *);
int (*disable_rx_vlan_filtering)(struct xgbe_prv_data *);
int (*update_vlan_hash_table)(struct xgbe_prv_data *);
int (*read_mmd_regs)(struct xgbe_prv_data *, int, int); int (*read_mmd_regs)(struct xgbe_prv_data *, int, int);
void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int); void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int);
...@@ -589,6 +595,9 @@ struct xgbe_prv_data { ...@@ -589,6 +595,9 @@ struct xgbe_prv_data {
struct napi_struct napi; struct napi_struct napi;
struct xgbe_mmc_stats mmc_stats; struct xgbe_mmc_stats mmc_stats;
/* Filtering support */
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
/* System clock value used for Rx watchdog */ /* System clock value used for Rx watchdog */
struct clk *sysclock; struct clk *sysclock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment