mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 20:14:06 +02:00
Merge branch 'amd-xgbe-introduce-support-for-ethtool-selftests'
Raju Rangoju says: ==================== amd-xgbe: introduce support for ethtool selftests This patch series introduces support for ethtool selftests, which helps in finding the misconfiguration of HW. Makes use of network selftest packet creation infrastructure. Supports the following tests: - MAC loopback selftest - PHY loopback selftest - Split header selftest - Jumbo frame selftest ==================== Link: https://patch.msgid.link/20251031111555.774425-1-Raju.Rangoju@amd.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
commit
f47b0c1182
|
|
@ -165,6 +165,7 @@ config AMD_XGBE
|
|||
select CRC32
|
||||
select PHYLIB
|
||||
select AMD_XGBE_HAVE_ECC if X86
|
||||
select NET_SELFTESTS
|
||||
help
|
||||
This driver supports the AMD 10GbE Ethernet device found on an
|
||||
AMD SoC.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ amd-xgbe-objs := xgbe-main.o xgbe-drv.o xgbe-dev.o \
|
|||
xgbe-desc.o xgbe-ethtool.o xgbe-mdio.o \
|
||||
xgbe-hwtstamp.o xgbe-ptp.o xgbe-pps.o \
|
||||
xgbe-i2c.o xgbe-phy-v1.o xgbe-phy-v2.o \
|
||||
xgbe-platform.o
|
||||
xgbe-platform.o xgbe-selftest.o
|
||||
|
||||
amd-xgbe-$(CONFIG_PCI) += xgbe-pci.o
|
||||
amd-xgbe-$(CONFIG_AMD_XGBE_DCB) += xgbe-dcb.o
|
||||
|
|
|
|||
|
|
@ -211,6 +211,7 @@ static void xgbe_config_sph_mode(struct xgbe_prv_data *pdata)
|
|||
}
|
||||
|
||||
XGMAC_IOWRITE_BITS(pdata, MAC_RCR, HDSMS, XGBE_SPH_HDSMS_SIZE);
|
||||
pdata->sph = true;
|
||||
}
|
||||
|
||||
static void xgbe_disable_sph_mode(struct xgbe_prv_data *pdata)
|
||||
|
|
@ -223,6 +224,7 @@ static void xgbe_disable_sph_mode(struct xgbe_prv_data *pdata)
|
|||
|
||||
XGMAC_DMA_IOWRITE_BITS(pdata->channel[i], DMA_CH_CR, SPH, 0);
|
||||
}
|
||||
pdata->sph = false;
|
||||
}
|
||||
|
||||
static int xgbe_write_rss_reg(struct xgbe_prv_data *pdata, unsigned int type,
|
||||
|
|
@ -3578,3 +3580,20 @@ void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *hw_if)
|
|||
|
||||
DBGPR("<--xgbe_init_function_ptrs\n");
|
||||
}
|
||||
|
||||
int xgbe_enable_mac_loopback(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
/* Enable MAC loopback mode */
|
||||
XGMAC_IOWRITE_BITS(pdata, MAC_RCR, LM, 1);
|
||||
|
||||
/* Wait for loopback to stabilize */
|
||||
usleep_range(10, 15);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void xgbe_disable_mac_loopback(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
/* Disable MAC loopback mode */
|
||||
XGMAC_IOWRITE_BITS(pdata, MAC_RCR, LM, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,6 +85,9 @@ static void xgbe_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
|
|||
int i;
|
||||
|
||||
switch (stringset) {
|
||||
case ETH_SS_TEST:
|
||||
xgbe_selftest_get_strings(pdata, data);
|
||||
break;
|
||||
case ETH_SS_STATS:
|
||||
for (i = 0; i < XGBE_STATS_COUNT; i++)
|
||||
ethtool_puts(&data, xgbe_gstring_stats[i].stat_string);
|
||||
|
|
@ -131,6 +134,9 @@ static int xgbe_get_sset_count(struct net_device *netdev, int stringset)
|
|||
int ret;
|
||||
|
||||
switch (stringset) {
|
||||
case ETH_SS_TEST:
|
||||
ret = xgbe_selftest_get_count(pdata);
|
||||
break;
|
||||
case ETH_SS_STATS:
|
||||
ret = XGBE_STATS_COUNT +
|
||||
(pdata->tx_ring_count * 2) +
|
||||
|
|
@ -760,6 +766,7 @@ static const struct ethtool_ops xgbe_ethtool_ops = {
|
|||
.set_ringparam = xgbe_set_ringparam,
|
||||
.get_channels = xgbe_get_channels,
|
||||
.set_channels = xgbe_set_channels,
|
||||
.self_test = xgbe_selftest_run,
|
||||
};
|
||||
|
||||
const struct ethtool_ops *xgbe_get_ethtool_ops(void)
|
||||
|
|
|
|||
346
drivers/net/ethernet/amd/xgbe/xgbe-selftest.c
Normal file
346
drivers/net/ethernet/amd/xgbe/xgbe-selftest.c
Normal file
|
|
@ -0,0 +1,346 @@
|
|||
// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-3-Clause)
|
||||
/*
|
||||
* Copyright (c) 2014-2025, Advanced Micro Devices, Inc.
|
||||
* Copyright (c) 2014, Synopsys, Inc.
|
||||
* All rights reserved
|
||||
*
|
||||
* Author: Raju Rangoju <Raju.Rangoju@amd.com>
|
||||
*/
|
||||
#include <linux/crc32.h>
|
||||
#include <linux/ip.h>
|
||||
#include <linux/udp.h>
|
||||
#include <net/tcp.h>
|
||||
#include <net/udp.h>
|
||||
#include <net/checksum.h>
|
||||
#include <net/selftests.h>
|
||||
|
||||
#include "xgbe.h"
|
||||
#include "xgbe-common.h"
|
||||
|
||||
#define XGBE_LOOPBACK_NONE 0
|
||||
#define XGBE_LOOPBACK_MAC 1
|
||||
#define XGBE_LOOPBACK_PHY 2
|
||||
|
||||
struct xgbe_test {
|
||||
char name[ETH_GSTRING_LEN];
|
||||
int lb;
|
||||
int (*fn)(struct xgbe_prv_data *pdata);
|
||||
};
|
||||
|
||||
static u8 xgbe_test_id;
|
||||
|
||||
static int xgbe_test_loopback_validate(struct sk_buff *skb,
|
||||
struct net_device *ndev,
|
||||
struct packet_type *pt,
|
||||
struct net_device *orig_ndev)
|
||||
{
|
||||
struct net_test_priv *tdata = pt->af_packet_priv;
|
||||
const unsigned char *dst = tdata->packet->dst;
|
||||
const unsigned char *src = tdata->packet->src;
|
||||
struct netsfhdr *hdr;
|
||||
struct ethhdr *eh;
|
||||
struct tcphdr *th;
|
||||
struct udphdr *uh;
|
||||
struct iphdr *ih;
|
||||
int eat;
|
||||
|
||||
skb = skb_unshare(skb, GFP_ATOMIC);
|
||||
if (!skb)
|
||||
goto out;
|
||||
|
||||
eat = (skb->tail + skb->data_len) - skb->end;
|
||||
if (eat > 0 && skb_shared(skb)) {
|
||||
skb = skb_share_check(skb, GFP_ATOMIC);
|
||||
if (!skb)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (skb_linearize(skb))
|
||||
goto out;
|
||||
|
||||
if (skb_headlen(skb) < (NET_TEST_PKT_SIZE - ETH_HLEN))
|
||||
goto out;
|
||||
|
||||
eh = (struct ethhdr *)skb_mac_header(skb);
|
||||
if (dst) {
|
||||
if (!ether_addr_equal_unaligned(eh->h_dest, dst))
|
||||
goto out;
|
||||
}
|
||||
if (src) {
|
||||
if (!ether_addr_equal_unaligned(eh->h_source, src))
|
||||
goto out;
|
||||
}
|
||||
|
||||
ih = ip_hdr(skb);
|
||||
|
||||
if (tdata->packet->tcp) {
|
||||
if (ih->protocol != IPPROTO_TCP)
|
||||
goto out;
|
||||
|
||||
th = (struct tcphdr *)((u8 *)ih + 4 * ih->ihl);
|
||||
if (th->dest != htons(tdata->packet->dport))
|
||||
goto out;
|
||||
|
||||
hdr = (struct netsfhdr *)((u8 *)th + sizeof(*th));
|
||||
} else {
|
||||
if (ih->protocol != IPPROTO_UDP)
|
||||
goto out;
|
||||
|
||||
uh = (struct udphdr *)((u8 *)ih + 4 * ih->ihl);
|
||||
if (uh->dest != htons(tdata->packet->dport))
|
||||
goto out;
|
||||
|
||||
hdr = (struct netsfhdr *)((u8 *)uh + sizeof(*uh));
|
||||
}
|
||||
|
||||
if (hdr->magic != cpu_to_be64(NET_TEST_PKT_MAGIC))
|
||||
goto out;
|
||||
if (tdata->packet->id != hdr->id)
|
||||
goto out;
|
||||
|
||||
tdata->ok = true;
|
||||
complete(&tdata->comp);
|
||||
out:
|
||||
kfree_skb(skb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __xgbe_test_loopback(struct xgbe_prv_data *pdata,
|
||||
struct net_packet_attrs *attr)
|
||||
{
|
||||
struct net_test_priv *tdata;
|
||||
struct sk_buff *skb = NULL;
|
||||
int ret = 0;
|
||||
|
||||
tdata = kzalloc(sizeof(*tdata), GFP_KERNEL);
|
||||
if (!tdata)
|
||||
return -ENOMEM;
|
||||
|
||||
tdata->ok = false;
|
||||
init_completion(&tdata->comp);
|
||||
|
||||
tdata->pt.type = htons(ETH_P_IP);
|
||||
tdata->pt.func = xgbe_test_loopback_validate;
|
||||
tdata->pt.dev = pdata->netdev;
|
||||
tdata->pt.af_packet_priv = tdata;
|
||||
tdata->packet = attr;
|
||||
|
||||
dev_add_pack(&tdata->pt);
|
||||
|
||||
skb = net_test_get_skb(pdata->netdev, xgbe_test_id, attr);
|
||||
if (!skb) {
|
||||
ret = -ENOMEM;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
xgbe_test_id++;
|
||||
ret = dev_direct_xmit(skb, attr->queue_mapping);
|
||||
if (ret)
|
||||
goto cleanup;
|
||||
|
||||
if (!attr->timeout)
|
||||
attr->timeout = NET_LB_TIMEOUT;
|
||||
|
||||
wait_for_completion_timeout(&tdata->comp, attr->timeout);
|
||||
ret = tdata->ok ? 0 : -ETIMEDOUT;
|
||||
|
||||
if (ret)
|
||||
netdev_err(pdata->netdev, "Response timedout: ret %d\n", ret);
|
||||
cleanup:
|
||||
dev_remove_pack(&tdata->pt);
|
||||
kfree(tdata);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int xgbe_test_mac_loopback(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct net_packet_attrs attr = {};
|
||||
|
||||
attr.dst = pdata->netdev->dev_addr;
|
||||
return __xgbe_test_loopback(pdata, &attr);
|
||||
}
|
||||
|
||||
static int xgbe_test_phy_loopback(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct net_packet_attrs attr = {};
|
||||
int ret;
|
||||
|
||||
if (!pdata->netdev->phydev) {
|
||||
netdev_err(pdata->netdev, "phydev not found: cannot start PHY loopback test\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
ret = phy_loopback(pdata->netdev->phydev, true, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
attr.dst = pdata->netdev->dev_addr;
|
||||
ret = __xgbe_test_loopback(pdata, &attr);
|
||||
|
||||
phy_loopback(pdata->netdev->phydev, false, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int xgbe_test_sph(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct net_packet_attrs attr = {};
|
||||
unsigned long cnt_end, cnt_start;
|
||||
int ret;
|
||||
|
||||
cnt_start = pdata->ext_stats.rx_split_header_packets;
|
||||
|
||||
if (!pdata->sph) {
|
||||
netdev_err(pdata->netdev, "Split Header not enabled\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/* UDP test */
|
||||
attr.dst = pdata->netdev->dev_addr;
|
||||
attr.tcp = false;
|
||||
|
||||
ret = __xgbe_test_loopback(pdata, &attr);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
cnt_end = pdata->ext_stats.rx_split_header_packets;
|
||||
if (cnt_end <= cnt_start)
|
||||
return -EINVAL;
|
||||
|
||||
/* TCP test */
|
||||
cnt_start = cnt_end;
|
||||
|
||||
attr.dst = pdata->netdev->dev_addr;
|
||||
attr.tcp = true;
|
||||
|
||||
ret = __xgbe_test_loopback(pdata, &attr);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
cnt_end = pdata->ext_stats.rx_split_header_packets;
|
||||
if (cnt_end <= cnt_start)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xgbe_test_jumbo(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct net_packet_attrs attr = {};
|
||||
int size = pdata->rx_buf_size;
|
||||
|
||||
attr.dst = pdata->netdev->dev_addr;
|
||||
attr.max_size = size - ETH_FCS_LEN;
|
||||
|
||||
return __xgbe_test_loopback(pdata, &attr);
|
||||
}
|
||||
|
||||
static const struct xgbe_test xgbe_selftests[] = {
|
||||
{
|
||||
.name = "MAC Loopback ",
|
||||
.lb = XGBE_LOOPBACK_MAC,
|
||||
.fn = xgbe_test_mac_loopback,
|
||||
}, {
|
||||
.name = "PHY Loopback ",
|
||||
.lb = XGBE_LOOPBACK_NONE,
|
||||
.fn = xgbe_test_phy_loopback,
|
||||
}, {
|
||||
.name = "Split Header ",
|
||||
.lb = XGBE_LOOPBACK_PHY,
|
||||
.fn = xgbe_test_sph,
|
||||
}, {
|
||||
.name = "Jumbo Frame ",
|
||||
.lb = XGBE_LOOPBACK_PHY,
|
||||
.fn = xgbe_test_jumbo,
|
||||
},
|
||||
};
|
||||
|
||||
void xgbe_selftest_run(struct net_device *dev,
|
||||
struct ethtool_test *etest, u64 *buf)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(dev);
|
||||
int count = xgbe_selftest_get_count(pdata);
|
||||
int i, ret;
|
||||
|
||||
memset(buf, 0, sizeof(*buf) * count);
|
||||
xgbe_test_id = 0;
|
||||
|
||||
if (etest->flags != ETH_TEST_FL_OFFLINE) {
|
||||
netdev_err(pdata->netdev, "Only offline tests are supported\n");
|
||||
etest->flags |= ETH_TEST_FL_FAILED;
|
||||
return;
|
||||
} else if (!netif_carrier_ok(dev)) {
|
||||
netdev_err(pdata->netdev,
|
||||
"Invalid link, cannot execute tests\n");
|
||||
etest->flags |= ETH_TEST_FL_FAILED;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Wait for queues drain */
|
||||
msleep(200);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
ret = 0;
|
||||
|
||||
switch (xgbe_selftests[i].lb) {
|
||||
case XGBE_LOOPBACK_PHY:
|
||||
ret = -EOPNOTSUPP;
|
||||
if (dev->phydev)
|
||||
ret = phy_loopback(dev->phydev, true, 0);
|
||||
if (!ret)
|
||||
break;
|
||||
fallthrough;
|
||||
case XGBE_LOOPBACK_MAC:
|
||||
ret = xgbe_enable_mac_loopback(pdata);
|
||||
break;
|
||||
case XGBE_LOOPBACK_NONE:
|
||||
break;
|
||||
default:
|
||||
ret = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* First tests will always be MAC / PHY loopback.
|
||||
* If any of them is not supported we abort earlier.
|
||||
*/
|
||||
if (ret) {
|
||||
netdev_err(pdata->netdev, "Loopback not supported\n");
|
||||
etest->flags |= ETH_TEST_FL_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = xgbe_selftests[i].fn(pdata);
|
||||
if (ret && (ret != -EOPNOTSUPP))
|
||||
etest->flags |= ETH_TEST_FL_FAILED;
|
||||
buf[i] = ret;
|
||||
|
||||
switch (xgbe_selftests[i].lb) {
|
||||
case XGBE_LOOPBACK_PHY:
|
||||
ret = -EOPNOTSUPP;
|
||||
if (dev->phydev)
|
||||
ret = phy_loopback(dev->phydev, false, 0);
|
||||
if (!ret)
|
||||
break;
|
||||
fallthrough;
|
||||
case XGBE_LOOPBACK_MAC:
|
||||
xgbe_disable_mac_loopback(pdata);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void xgbe_selftest_get_strings(struct xgbe_prv_data *pdata, u8 *data)
|
||||
{
|
||||
u8 *p = data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < xgbe_selftest_get_count(pdata); i++)
|
||||
ethtool_puts(&p, xgbe_selftests[i].name);
|
||||
}
|
||||
|
||||
int xgbe_selftest_get_count(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
return ARRAY_SIZE(xgbe_selftests);
|
||||
}
|
||||
|
|
@ -1246,6 +1246,7 @@ struct xgbe_prv_data {
|
|||
int rx_adapt_retries;
|
||||
bool rx_adapt_done;
|
||||
bool mode_set;
|
||||
bool sph;
|
||||
};
|
||||
|
||||
/* Function prototypes*/
|
||||
|
|
@ -1322,6 +1323,16 @@ void xgbe_update_tstamp_time(struct xgbe_prv_data *pdata, unsigned int sec,
|
|||
int xgbe_pps_config(struct xgbe_prv_data *pdata, struct xgbe_pps_config *cfg,
|
||||
int index, bool on);
|
||||
|
||||
/* Selftest functions */
|
||||
void xgbe_selftest_run(struct net_device *dev,
|
||||
struct ethtool_test *etest, u64 *buf);
|
||||
void xgbe_selftest_get_strings(struct xgbe_prv_data *pdata, u8 *data);
|
||||
int xgbe_selftest_get_count(struct xgbe_prv_data *pdata);
|
||||
|
||||
/* Loopback control */
|
||||
int xgbe_enable_mac_loopback(struct xgbe_prv_data *pdata);
|
||||
void xgbe_disable_mac_loopback(struct xgbe_prv_data *pdata);
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
void xgbe_debugfs_init(struct xgbe_prv_data *);
|
||||
void xgbe_debugfs_exit(struct xgbe_prv_data *);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,48 @@
|
|||
#define _NET_SELFTESTS
|
||||
|
||||
#include <linux/ethtool.h>
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
struct net_packet_attrs {
|
||||
const unsigned char *src;
|
||||
const unsigned char *dst;
|
||||
u32 ip_src;
|
||||
u32 ip_dst;
|
||||
bool tcp;
|
||||
u16 sport;
|
||||
u16 dport;
|
||||
int timeout;
|
||||
int size;
|
||||
int max_size;
|
||||
u8 id;
|
||||
u16 queue_mapping;
|
||||
bool bad_csum;
|
||||
};
|
||||
|
||||
struct net_test_priv {
|
||||
struct net_packet_attrs *packet;
|
||||
struct packet_type pt;
|
||||
struct completion comp;
|
||||
int double_vlan;
|
||||
int vlan_id;
|
||||
int ok;
|
||||
};
|
||||
|
||||
struct netsfhdr {
|
||||
__be32 version;
|
||||
__be64 magic;
|
||||
u8 id;
|
||||
} __packed;
|
||||
|
||||
#define NET_TEST_PKT_SIZE (sizeof(struct ethhdr) + sizeof(struct iphdr) + \
|
||||
sizeof(struct netsfhdr))
|
||||
#define NET_TEST_PKT_MAGIC 0xdeadcafecafedeadULL
|
||||
#define NET_LB_TIMEOUT msecs_to_jiffies(200)
|
||||
|
||||
#if IS_ENABLED(CONFIG_NET_SELFTESTS)
|
||||
|
||||
struct sk_buff *net_test_get_skb(struct net_device *ndev, u8 id,
|
||||
struct net_packet_attrs *attr);
|
||||
void net_selftest(struct net_device *ndev, struct ethtool_test *etest,
|
||||
u64 *buf);
|
||||
int net_selftest_get_count(void);
|
||||
|
|
@ -13,6 +52,12 @@ void net_selftest_get_strings(u8 *data);
|
|||
|
||||
#else
|
||||
|
||||
static inline struct sk_buff *net_test_get_skb(struct net_device *ndev, u8 id,
|
||||
struct net_packet_attrs *attr)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void net_selftest(struct net_device *ndev, struct ethtool_test *etest,
|
||||
u64 *buf)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,46 +14,10 @@
|
|||
#include <net/tcp.h>
|
||||
#include <net/udp.h>
|
||||
|
||||
struct net_packet_attrs {
|
||||
const unsigned char *src;
|
||||
const unsigned char *dst;
|
||||
u32 ip_src;
|
||||
u32 ip_dst;
|
||||
bool tcp;
|
||||
u16 sport;
|
||||
u16 dport;
|
||||
int timeout;
|
||||
int size;
|
||||
int max_size;
|
||||
u8 id;
|
||||
u16 queue_mapping;
|
||||
bool bad_csum;
|
||||
};
|
||||
|
||||
struct net_test_priv {
|
||||
struct net_packet_attrs *packet;
|
||||
struct packet_type pt;
|
||||
struct completion comp;
|
||||
int double_vlan;
|
||||
int vlan_id;
|
||||
int ok;
|
||||
};
|
||||
|
||||
struct netsfhdr {
|
||||
__be32 version;
|
||||
__be64 magic;
|
||||
u8 id;
|
||||
} __packed;
|
||||
|
||||
static u8 net_test_next_id;
|
||||
|
||||
#define NET_TEST_PKT_SIZE (sizeof(struct ethhdr) + sizeof(struct iphdr) + \
|
||||
sizeof(struct netsfhdr))
|
||||
#define NET_TEST_PKT_MAGIC 0xdeadcafecafedeadULL
|
||||
#define NET_LB_TIMEOUT msecs_to_jiffies(200)
|
||||
|
||||
static struct sk_buff *net_test_get_skb(struct net_device *ndev,
|
||||
struct net_packet_attrs *attr)
|
||||
struct sk_buff *net_test_get_skb(struct net_device *ndev, u8 id,
|
||||
struct net_packet_attrs *attr)
|
||||
{
|
||||
struct sk_buff *skb = NULL;
|
||||
struct udphdr *uhdr = NULL;
|
||||
|
|
@ -142,8 +106,8 @@ static struct sk_buff *net_test_get_skb(struct net_device *ndev,
|
|||
shdr = skb_put(skb, sizeof(*shdr));
|
||||
shdr->version = 0;
|
||||
shdr->magic = cpu_to_be64(NET_TEST_PKT_MAGIC);
|
||||
attr->id = net_test_next_id;
|
||||
shdr->id = net_test_next_id++;
|
||||
attr->id = id;
|
||||
shdr->id = id;
|
||||
|
||||
if (attr->size) {
|
||||
void *payload = skb_put(skb, attr->size);
|
||||
|
|
@ -190,6 +154,7 @@ static struct sk_buff *net_test_get_skb(struct net_device *ndev,
|
|||
|
||||
return skb;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(net_test_get_skb);
|
||||
|
||||
static int net_test_loopback_validate(struct sk_buff *skb,
|
||||
struct net_device *ndev,
|
||||
|
|
@ -286,12 +251,13 @@ static int __net_test_loopback(struct net_device *ndev,
|
|||
tpriv->packet = attr;
|
||||
dev_add_pack(&tpriv->pt);
|
||||
|
||||
skb = net_test_get_skb(ndev, attr);
|
||||
skb = net_test_get_skb(ndev, net_test_next_id, attr);
|
||||
if (!skb) {
|
||||
ret = -ENOMEM;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
net_test_next_id++;
|
||||
ret = dev_direct_xmit(skb, attr->queue_mapping);
|
||||
if (ret < 0) {
|
||||
goto cleanup;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user