1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/netdevice.h>
4 #include <linux/mctp.h>
5 #include <linux/if_arp.h>
8 #include <net/mctpdevice.h>
9 #include <net/pkt_sched.h>
13 static netdev_tx_t
mctp_test_dev_tx(struct sk_buff
*skb
,
14 struct net_device
*ndev
)
20 static const struct net_device_ops mctp_test_netdev_ops
= {
21 .ndo_start_xmit
= mctp_test_dev_tx
,
24 static void mctp_test_dev_setup(struct net_device
*ndev
)
26 ndev
->type
= ARPHRD_MCTP
;
27 ndev
->mtu
= MCTP_DEV_TEST_MTU
;
28 ndev
->hard_header_len
= 0;
30 ndev
->tx_queue_len
= DEFAULT_TX_QUEUE_LEN
;
31 ndev
->flags
= IFF_NOARP
;
32 ndev
->netdev_ops
= &mctp_test_netdev_ops
;
33 ndev
->needs_free_netdev
= true;
36 struct mctp_test_dev
*mctp_test_create_dev(void)
38 struct mctp_test_dev
*dev
;
39 struct net_device
*ndev
;
42 ndev
= alloc_netdev(sizeof(*dev
), "mctptest%d", NET_NAME_ENUM
,
47 dev
= netdev_priv(ndev
);
50 rc
= register_netdev(ndev
);
57 dev
->mdev
= __mctp_dev_get(ndev
);
58 dev
->mdev
->net
= mctp_default_net(dev_net(ndev
));
64 void mctp_test_destroy_dev(struct mctp_test_dev
*dev
)
66 mctp_dev_put(dev
->mdev
);
67 unregister_netdev(dev
->ndev
);