diff options
author | Madalin Bucur <madalin.bucur@nxp.com> | 2017-08-27 16:13:41 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-08-29 02:41:00 +0300 |
commit | 056057e288e70755a423ddfd2e45b97cd147a411 (patch) | |
tree | cd74a0a65449c37009cf7bb0543ec8472dfcdf02 /drivers/net/ethernet/freescale/dpaa | |
parent | bcf0994b23fed62cfd55e922e74b0dd43958e6fd (diff) | |
download | linux-056057e288e70755a423ddfd2e45b97cd147a411.tar.xz |
dpaa_eth: add NETIF_F_RXHASH
Set the skb hash when then FMan Keygen hash result is available.
Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/freescale/dpaa')
-rw-r--r-- | drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 23 | ||||
-rw-r--r-- | drivers/net/ethernet/freescale/dpaa/dpaa_eth.h | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 9 |
3 files changed, 28 insertions, 5 deletions
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 6d89e74ded5c..73ca8d761e18 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -236,7 +236,7 @@ static int dpaa_netdev_init(struct net_device *net_dev, net_dev->max_mtu = dpaa_get_max_mtu(); net_dev->hw_features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | - NETIF_F_LLTX); + NETIF_F_LLTX | NETIF_F_RXHASH); net_dev->hw_features |= NETIF_F_SG | NETIF_F_HIGHDMA; /* The kernels enables GSO automatically, if we declare NETIF_F_SG. @@ -2237,12 +2237,13 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal, dma_addr_t addr = qm_fd_addr(fd); enum qm_fd_format fd_format; struct net_device *net_dev; - u32 fd_status; + u32 fd_status, hash_offset; struct dpaa_bp *dpaa_bp; struct dpaa_priv *priv; unsigned int skb_len; struct sk_buff *skb; int *count_ptr; + void *vaddr; fd_status = be32_to_cpu(fd->status); fd_format = qm_fd_get_format(fd); @@ -2288,7 +2289,8 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal, dma_unmap_single(dpaa_bp->dev, addr, dpaa_bp->size, DMA_FROM_DEVICE); /* prefetch the first 64 bytes of the frame or the SGT start */ - prefetch(phys_to_virt(addr) + qm_fd_get_offset(fd)); + vaddr = phys_to_virt(addr); + prefetch(vaddr + qm_fd_get_offset(fd)); fd_format = qm_fd_get_format(fd); /* The only FD types that we may receive are contig and S/G */ @@ -2309,6 +2311,18 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal, skb->protocol = eth_type_trans(skb, net_dev); + if (net_dev->features & NETIF_F_RXHASH && priv->keygen_in_use && + !fman_port_get_hash_result_offset(priv->mac_dev->port[RX], + &hash_offset)) { + enum pkt_hash_types type; + + /* if L4 exists, it was used in the hash generation */ + type = be32_to_cpu(fd->status) & FM_FD_STAT_L4CV ? + PKT_HASH_TYPE_L4 : PKT_HASH_TYPE_L3; + skb_set_hash(skb, be32_to_cpu(*(u32 *)(vaddr + hash_offset)), + type); + } + skb_len = skb->len; if (unlikely(netif_receive_skb(skb) == NET_RX_DROP)) @@ -2774,6 +2788,9 @@ static int dpaa_eth_probe(struct platform_device *pdev) if (err) goto init_ports_failed; + /* Rx traffic distribution based on keygen hashing defaults to on */ + priv->keygen_in_use = true; + priv->percpu_priv = devm_alloc_percpu(dev, *priv->percpu_priv); if (!priv->percpu_priv) { dev_err(dev, "devm_alloc_percpu() failed\n"); diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h index 496a12c50ada..bd9422082f83 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.h @@ -159,6 +159,7 @@ struct dpaa_priv { struct list_head dpaa_fq_list; u8 num_tc; + bool keygen_in_use; u32 msg_enable; /* net_device message level */ struct { diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c index 965f6520d58a..faea674094b9 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c @@ -402,6 +402,8 @@ static void dpaa_get_strings(struct net_device *net_dev, u32 stringset, static int dpaa_get_hash_opts(struct net_device *dev, struct ethtool_rxnfc *cmd) { + struct dpaa_priv *priv = netdev_priv(dev); + cmd->data = 0; switch (cmd->flow_type) { @@ -409,7 +411,8 @@ static int dpaa_get_hash_opts(struct net_device *dev, case TCP_V6_FLOW: case UDP_V4_FLOW: case UDP_V6_FLOW: - cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; + if (priv->keygen_in_use) + cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; /* Fall through */ case IPV4_FLOW: case IPV6_FLOW: @@ -421,7 +424,8 @@ static int dpaa_get_hash_opts(struct net_device *dev, case AH_V6_FLOW: case ESP_V4_FLOW: case ESP_V6_FLOW: - cmd->data |= RXH_IP_SRC | RXH_IP_DST; + if (priv->keygen_in_use) + cmd->data |= RXH_IP_SRC | RXH_IP_DST; break; default: cmd->data = 0; @@ -458,6 +462,7 @@ static void dpaa_set_hash(struct net_device *net_dev, bool enable) rxport = mac_dev->port[0]; fman_port_use_kg_hash(rxport, enable); + priv->keygen_in_use = enable; } static int dpaa_set_hash_opts(struct net_device *dev, |