sfc: hook up ef100 representor TX
authorEdward Cree <ecree.xilinx@gmail.com>
Wed, 20 Jul 2022 18:33:48 +0000 (19:33 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 22 Jul 2022 11:50:06 +0000 (12:50 +0100)
Implement .ndo_start_xmit() by calling into the parent PF's TX path.

Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/sfc/ef100_netdev.c
drivers/net/ethernet/sfc/ef100_netdev.h
drivers/net/ethernet/sfc/ef100_rep.c

index f4a124b..3443477 100644 (file)
@@ -195,6 +195,15 @@ static netdev_tx_t ef100_hard_start_xmit(struct sk_buff *skb,
                                         struct net_device *net_dev)
 {
        struct efx_nic *efx = efx_netdev_priv(net_dev);
+
+       return __ef100_hard_start_xmit(skb, efx, net_dev, NULL);
+}
+
+netdev_tx_t __ef100_hard_start_xmit(struct sk_buff *skb,
+                                   struct efx_nic *efx,
+                                   struct net_device *net_dev,
+                                   struct efx_rep *efv)
+{
        struct efx_tx_queue *tx_queue;
        struct efx_channel *channel;
        int rc;
@@ -209,7 +218,7 @@ static netdev_tx_t ef100_hard_start_xmit(struct sk_buff *skb,
        }
 
        tx_queue = &channel->tx_queue[0];
-       rc = ef100_enqueue_skb(tx_queue, skb);
+       rc = __ef100_enqueue_skb(tx_queue, skb, efv);
        if (rc == 0)
                return NETDEV_TX_OK;
 
index 38b032b..86bf985 100644 (file)
  */
 
 #include <linux/netdevice.h>
+#include "ef100_rep.h"
 
+netdev_tx_t __ef100_hard_start_xmit(struct sk_buff *skb,
+                                   struct efx_nic *efx,
+                                   struct net_device *net_dev,
+                                   struct efx_rep *efv);
 int ef100_netdev_event(struct notifier_block *this,
                       unsigned long event, void *ptr);
 int ef100_probe_netdev(struct efx_probe_data *probe_data);
index cf0eac9..6d4c3f0 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include "ef100_rep.h"
+#include "ef100_netdev.h"
 #include "ef100_nic.h"
 #include "mae.h"
 
@@ -28,6 +29,25 @@ static int efx_ef100_rep_init_struct(struct efx_nic *efx, struct efx_rep *efv,
        return 0;
 }
 
+static netdev_tx_t efx_ef100_rep_xmit(struct sk_buff *skb,
+                                     struct net_device *dev)
+{
+       struct efx_rep *efv = netdev_priv(dev);
+       struct efx_nic *efx = efv->parent;
+       netdev_tx_t rc;
+
+       /* __ef100_hard_start_xmit() will always return success even in the
+        * case of TX drops, where it will increment efx's tx_dropped.  The
+        * efv stats really only count attempted TX, not success/failure.
+        */
+       atomic64_inc(&efv->stats.tx_packets);
+       atomic64_add(skb->len, &efv->stats.tx_bytes);
+       netif_tx_lock(efx->net_dev);
+       rc = __ef100_hard_start_xmit(skb, efx, dev, efv);
+       netif_tx_unlock(efx->net_dev);
+       return rc;
+}
+
 static int efx_ef100_rep_get_port_parent_id(struct net_device *dev,
                                            struct netdev_phys_item_id *ppid)
 {
@@ -60,6 +80,7 @@ static int efx_ef100_rep_get_phys_port_name(struct net_device *dev,
 }
 
 static const struct net_device_ops efx_ef100_rep_netdev_ops = {
+       .ndo_start_xmit         = efx_ef100_rep_xmit,
        .ndo_get_port_parent_id = efx_ef100_rep_get_port_parent_id,
        .ndo_get_phys_port_name = efx_ef100_rep_get_phys_port_name,
 };
@@ -119,6 +140,8 @@ static struct efx_rep *efx_ef100_rep_create_netdev(struct efx_nic *efx,
        net_dev->ethtool_ops = &efx_ef100_rep_ethtool_ops;
        net_dev->min_mtu = EFX_MIN_MTU;
        net_dev->max_mtu = EFX_MAX_MTU;
+       net_dev->features |= NETIF_F_LLTX;
+       net_dev->hw_features |= NETIF_F_LLTX;
        return efv;
 fail1:
        free_netdev(net_dev);