new Fungible Ethernet driver
Subsystems (4)
v2 cover new Fungible Ethernet driver
This patch series contains a new network driver for the Ethernet functionality of Fungible cards.
It contains two modules. The first one in patch 2 is a library module that implements some of the device setup, queue managenent, and support for operating an admin queue. These are placed in a separate module because the cards provide a number of PCI functions handled by different types of drivers and all use the same common means to interact with the device. Each of the drivers will be relying on this library module for them.
The remaining patches provide the Ethernet driver for the cards.
v2:
- Fix set_pauseparam, remove get_wol, remove module param (Andrew Lunn)
- Fix a register poll loop (Andrew)
- Replace constants defined with 'static const'
- make W=1 C=1 is clean
- Remove devlink FW update (Jakub)
- Remove duplicate ethtool stats covered by structured API (Jakub)
Dimitris Michailidis (8):
PCI: add Fungible vendor ID to pci_ids.h net/fungible: Add service module for Fungible drivers net/funeth: probing and netdev ops net/funeth: ethtool operations
net/funeth: devlink support
net/funeth: add the data path
net/funeth: add kTLS TX control part net/fungible: Kconfig, Makefiles, and MAINTAINERS
MAINTAINERS | 6 + drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/fungible/Kconfig | 27 + drivers/net/ethernet/fungible/Makefile | 7 + .../net/ethernet/fungible/funcore/Makefile | 5 + .../net/ethernet/fungible/funcore/fun_dev.c | 846 ++++++++ .../net/ethernet/fungible/funcore/fun_dev.h | 151 ++ .../net/ethernet/fungible/funcore/fun_hci.h | 1187 +++++++++++ .../net/ethernet/fungible/funcore/fun_queue.c | 620 ++++++ .../net/ethernet/fungible/funcore/fun_queue.h | 178 ++ drivers/net/ethernet/fungible/funeth/Kconfig | 17 + drivers/net/ethernet/fungible/funeth/Makefile | 10 + .../net/ethernet/fungible/funeth/fun_port.h | 97 + drivers/net/ethernet/fungible/funeth/funeth.h | 151 ++ .../ethernet/fungible/funeth/funeth_devlink.c | 40 + .../ethernet/fungible/funeth/funeth_devlink.h | 13 + .../ethernet/fungible/funeth/funeth_ethtool.c | 1182 +++++++++++ .../ethernet/fungible/funeth/funeth_ktls.c | 181 ++ .../ethernet/fungible/funeth/funeth_ktls.h | 33 + .../ethernet/fungible/funeth/funeth_main.c | 1773 +++++++++++++++++ .../net/ethernet/fungible/funeth/funeth_rx.c | 725 +++++++ .../ethernet/fungible/funeth/funeth_trace.h | 117 ++ .../net/ethernet/fungible/funeth/funeth_tx.c | 701 +++++++ .../ethernet/fungible/funeth/funeth_txrx.h | 242 +++ include/linux/pci_ids.h | 2 + 26 files changed, 8313 insertions(+) create mode 100644 drivers/net/ethernet/fungible/Kconfig create mode 100644 drivers/net/ethernet/fungible/Makefile create mode 100644 drivers/net/ethernet/fungible/funcore/Makefile create mode 100644 drivers/net/ethernet/fungible/funcore/fun_dev.c create mode 100644 drivers/net/ethernet/fungible/funcore/fun_dev.h create mode 100644 drivers/net/ethernet/fungible/funcore/fun_hci.h create mode 100644 drivers/net/ethernet/fungible/funcore/fun_queue.c create mode 100644 drivers/net/ethernet/fungible/funcore/fun_queue.h create mode 100644 drivers/net/ethernet/fungible/funeth/Kconfig create mode 100644 drivers/net/ethernet/fungible/funeth/Makefile create mode 100644 drivers/net/ethernet/fungible/funeth/fun_port.h create mode 100644 drivers/net/ethernet/fungible/funeth/funeth.h create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_devlink.c create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_devlink.h create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_ethtool.c create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_ktls.c create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_ktls.h create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_main.c create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_rx.c create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_trace.h create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_tx.c create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_txrx.h
Signature · 1 line
2.25.1
PATCH v2 1/8 PCI: add Fungible vendor ID to pci_ids.h
--- include/linux/pci_ids.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/pci_ids.h +2 -0
@@ -2578,6 +2578,8 @@#define PCI_VENDOR_ID_HYGON 0x1d94 +#define PCI_VENDOR_ID_FUNGIBLE 0x1dad +#define PCI_VENDOR_ID_HXT 0x1dbf#define PCI_VENDOR_ID_TEKRAM 0x1de1
Signature · 1 line
2.25.1
PATCH v2 2/8 net/fungible: Add service module for Fungible drivers
In reply to Dimitris MichailidisFungible cards have a number of different PCI functions and thus different drivers, all of which use a common method to initialize and interact with the device. This commit adds a library module that collects these common mechanisms. They mainly deal with device initialization, setting up and destroying queues, and operating an admin queue. A subset of the FW interface is also included here.
--- .../net/ethernet/fungible/funcore/Makefile | 5 + .../net/ethernet/fungible/funcore/fun_dev.c | 846 ++++++++++++ .../net/ethernet/fungible/funcore/fun_dev.h | 151 +++ .../net/ethernet/fungible/funcore/fun_hci.h | 1187 +++++++++++++++++ .../net/ethernet/fungible/funcore/fun_queue.c | 620 +++++++++ .../net/ethernet/fungible/funcore/fun_queue.h | 178 +++ 6 files changed, 2987 insertions(+) create mode 100644 drivers/net/ethernet/fungible/funcore/Makefile create mode 100644 drivers/net/ethernet/fungible/funcore/fun_dev.c create mode 100644 drivers/net/ethernet/fungible/funcore/fun_dev.h create mode 100644 drivers/net/ethernet/fungible/funcore/fun_hci.h create mode 100644 drivers/net/ethernet/fungible/funcore/fun_queue.c create mode 100644 drivers/net/ethernet/fungible/funcore/fun_queue.h
drivers/net/ethernet/fungible/funcore/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) + +obj-$(CONFIG_FUN_CORE) += funcore.o + +funcore-y := fun_dev.o fun_queue.o
drivers/net/ethernet/fungible/funcore/fun_dev.c new file +846 -0
846 lines not on this page · raw message
drivers/net/ethernet/fungible/funcore/fun_dev.h new file +151 -0
151 lines not on this page · raw message
drivers/net/ethernet/fungible/funcore/fun_hci.h new file +1187 -0
1,187 lines not on this page · raw message
drivers/net/ethernet/fungible/funcore/fun_queue.c new file +620 -0
620 lines not on this page · raw message
drivers/net/ethernet/fungible/funcore/fun_queue.h new file +178 -0
178 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 3/8 net/funeth: probing and netdev ops
In reply to Dimitris MichailidisThis is the first part of the Fungible ethernet driver. It deals with device probing, net_device creation, and netdev ops.
--- drivers/net/ethernet/fungible/funeth/funeth.h | 151 ++ .../ethernet/fungible/funeth/funeth_main.c | 1773 +++++++++++++++++ 2 files changed, 1924 insertions(+) create mode 100644 drivers/net/ethernet/fungible/funeth/funeth.h create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_main.c
drivers/net/ethernet/fungible/funeth/funeth.h new file +151 -0
@@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ + +#ifndef _FUNETH_H +#define _FUNETH_H + +#include <uapi/linux/if_ether.h> +#include <uapi/linux/net_tstamp.h> +#include <linux/seqlock.h> +#include <net/devlink.h> +#include "fun_dev.h" + +#define ADMIN_SQE_SIZE SZ_128 +#define ADMIN_CQE_SIZE SZ_64 +#define ADMIN_RSP_MAX_LEN (ADMIN_CQE_SIZE - sizeof(struct fun_cqe_info)) + +#define FUN_MAX_MTU 9024 + +#define SQ_DEPTH 512U +#define CQ_DEPTH 1024U +#define RQ_DEPTH (512U / (PAGE_SIZE / 4096)) + +#define CQ_INTCOAL_USEC 10 +#define CQ_INTCOAL_NPKT 16 +#define SQ_INTCOAL_USEC 10 +#define SQ_INTCOAL_NPKT 16 + +#define INVALID_LPORT 0xffff + +#define FUN_PORT_CAP_PAUSE_MASK (FUN_PORT_CAP_TX_PAUSE | FUN_PORT_CAP_RX_PAUSE) + +struct fun_vport_info { +u8 mac[ETH_ALEN ]; +u16 vlan; +__be16 vlan_proto; +u8 qos; +u8 spoofchk:1 ; +u8 trusted:1 ; +unsigned int max_rate; +}; + +/* "subclass" of fun_dev for Ethernet functions */ +struct fun_ethdev { +struct fun_dev fdev; + +/* the function's network ports */ +struct net_device **netdevs; +unsigned int num_ports; + +/* configuration for the function's virtual ports */ +unsigned int num_vports; +struct fun_vport_info *vport_info; + +unsigned int nsqs_per_port; +}; + +static inline struct fun_ethdev *to_fun_ethdev (struct fun_dev *p) +{ + return container_of(p, struct fun_ethdev, fdev); +} + +/* Per netdevice driver state, i.e., netdev_priv. */ +struct funeth_priv { +struct fun_dev *fdev; +struct pci_dev *pdev; +struct net_device *netdev; + +struct funeth_rxq *__rcu *rxqs; +struct funeth_txq **txqs; +struct funeth_txq **xdpqs; + +struct fun_irq *irqs; +unsigned int num_irqs; +unsigned int num_tx_irqs; + +unsigned int lane_attrs; +u16 lport; + +/* link settings */ +u64 port_caps; +u64 advertising; +u64 lp_advertising; +unsigned int link_speed; +u8 xcvr_type; +u8 active_fc; +u8 active_fec; +u8 link_down_reason; +seqcount_t link_seq; + +u32 msg_enable; + +unsigned int ethid_start; + +unsigned int num_xdpqs; + +/* ethtool, etc. config parameters */ +unsigned int sq_depth; +unsigned int rq_depth; +unsigned int cq_depth; +unsigned int cq_irq_db; +u8 tx_coal_usec; +u8 tx_coal_count; +u8 rx_coal_usec; +u8 rx_coal_count; + +struct hwtstamp_config hwtstamp_cfg; + +/* cumulative queue stats from earlier queue instances */ +u64 tx_packets; +u64 tx_bytes; +u64 tx_dropped; +u64 rx_packets; +u64 rx_bytes; +u64 rx_dropped; + +/* RSS */ +unsigned int rss_hw_id; +enum fun_eth_hash_alg hash_algo; +u8 rss_key[FUN_ETH_RSS_MAX_KEY_SIZE ]; +unsigned int indir_table_nentries; +u32 indir_table[FUN_ETH_RSS_MAX_INDIR_ENT ]; +dma_addr_t rss_dma_addr; +void *rss_cfg; + +/* DMA area for port stats */ +dma_addr_t stats_dma_addr; +__be64 *stats; + +struct bpf_prog *xdp_prog; + +struct devlink_port dl_port; + +/* kTLS state */ +unsigned int ktls_id; +atomic64_t tx_tls_add; +atomic64_t tx_tls_del; +atomic64_t tx_tls_resync; +}; + +void fun_set_ethtool_ops (struct net_device *netdev); +int fun_port_write_cmd (struct funeth_priv *fp,int key,u64 data); +int fun_port_read_cmd (struct funeth_priv *fp,int key,u64 *data); +int fun_create_and_bind_tx (struct funeth_priv *fp,u32 ethid,u32 sqid); +void fun_reset_rss_indir (struct net_device *dev); +int fun_config_rss (struct net_device *dev,int algo,const u8 *key, +const u32 *qtable,u8 op); + +int fun_alloc_rings (struct net_device *netdev); +void fun_free_rings (struct net_device *netdev); +int fun_alloc_queue_irqs (struct net_device *dev); + +#endif /* _FUNETH_H */
drivers/net/ethernet/fungible/funeth/funeth_main.c new file +1773 -0
1,773 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 4/8 net/funeth: ethtool operations
In reply to Dimitris MichailidisAdd ethtool operations, primarily related to queues and ports, as well as device statistics.
--- .../net/ethernet/fungible/funeth/fun_port.h | 97 ++ .../ethernet/fungible/funeth/funeth_ethtool.c | 1182 +++++++++++++++++ 2 files changed, 1279 insertions(+) create mode 100644 drivers/net/ethernet/fungible/funeth/fun_port.h create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_ethtool.c
drivers/net/ethernet/fungible/funeth/fun_port.h new file +97 -0
@@ -0,0 +1,97 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ + +#ifndef _FUN_PORT_H +#define _FUN_PORT_H + +enum port_mac_rx_stats { + PORT_MAC_RX_etherStatsOctets =0x0 , + PORT_MAC_RX_OctetsReceivedOK =0x1 , + PORT_MAC_RX_aAlignmentErrors =0x2 , + PORT_MAC_RX_aPAUSEMACCtrlFramesReceived =0x3 , + PORT_MAC_RX_aFrameTooLongErrors =0x4 , + PORT_MAC_RX_aInRangeLengthErrors =0x5 , + PORT_MAC_RX_aFramesReceivedOK =0x6 , + PORT_MAC_RX_aFrameCheckSequenceErrors =0x7 , + PORT_MAC_RX_VLANReceivedOK =0x8 , + PORT_MAC_RX_ifInErrors =0x9 , + PORT_MAC_RX_ifInUcastPkts =0xa , + PORT_MAC_RX_ifInMulticastPkts =0xb , + PORT_MAC_RX_ifInBroadcastPkts =0xc , + PORT_MAC_RX_etherStatsDropEvents =0xd , + PORT_MAC_RX_etherStatsPkts =0xe , + PORT_MAC_RX_etherStatsUndersizePkts =0xf , + PORT_MAC_RX_etherStatsPkts64Octets =0x10 , + PORT_MAC_RX_etherStatsPkts65to127Octets =0x11 , + PORT_MAC_RX_etherStatsPkts128to255Octets =0x12 , + PORT_MAC_RX_etherStatsPkts256to511Octets =0x13 , + PORT_MAC_RX_etherStatsPkts512to1023Octets =0x14 , + PORT_MAC_RX_etherStatsPkts1024to1518Octets =0x15 , + PORT_MAC_RX_etherStatsPkts1519toMaxOctets =0x16 , + PORT_MAC_RX_etherStatsOversizePkts =0x17 , + PORT_MAC_RX_etherStatsJabbers =0x18 , + PORT_MAC_RX_etherStatsFragments =0x19 , + PORT_MAC_RX_CBFCPAUSEFramesReceived_0 =0x1a , + PORT_MAC_RX_CBFCPAUSEFramesReceived_1 =0x1b , + PORT_MAC_RX_CBFCPAUSEFramesReceived_2 =0x1c , + PORT_MAC_RX_CBFCPAUSEFramesReceived_3 =0x1d , + PORT_MAC_RX_CBFCPAUSEFramesReceived_4 =0x1e , + PORT_MAC_RX_CBFCPAUSEFramesReceived_5 =0x1f , + PORT_MAC_RX_CBFCPAUSEFramesReceived_6 =0x20 , + PORT_MAC_RX_CBFCPAUSEFramesReceived_7 =0x21 , + PORT_MAC_RX_CBFCPAUSEFramesReceived_8 =0x22 , + PORT_MAC_RX_CBFCPAUSEFramesReceived_9 =0x23 , + PORT_MAC_RX_CBFCPAUSEFramesReceived_10 =0x24 , + PORT_MAC_RX_CBFCPAUSEFramesReceived_11 =0x25 , + PORT_MAC_RX_CBFCPAUSEFramesReceived_12 =0x26 , + PORT_MAC_RX_CBFCPAUSEFramesReceived_13 =0x27 , + PORT_MAC_RX_CBFCPAUSEFramesReceived_14 =0x28 , + PORT_MAC_RX_CBFCPAUSEFramesReceived_15 =0x29 , + PORT_MAC_RX_MACControlFramesReceived =0x2a , +PORT_MAC_RX_STATS_MAX =0x2b , +}; + +enum port_mac_tx_stats { + PORT_MAC_TX_etherStatsOctets =0x0 , + PORT_MAC_TX_OctetsTransmittedOK =0x1 , + PORT_MAC_TX_aPAUSEMACCtrlFramesTransmitted =0x2 , + PORT_MAC_TX_aFramesTransmittedOK =0x3 , + PORT_MAC_TX_VLANTransmittedOK =0x4 , + PORT_MAC_TX_ifOutErrors =0x5 , + PORT_MAC_TX_ifOutUcastPkts =0x6 , + PORT_MAC_TX_ifOutMulticastPkts =0x7 , + PORT_MAC_TX_ifOutBroadcastPkts =0x8 , + PORT_MAC_TX_etherStatsPkts64Octets =0x9 , + PORT_MAC_TX_etherStatsPkts65to127Octets =0xa , + PORT_MAC_TX_etherStatsPkts128to255Octets =0xb , + PORT_MAC_TX_etherStatsPkts256to511Octets =0xc , + PORT_MAC_TX_etherStatsPkts512to1023Octets =0xd , + PORT_MAC_TX_etherStatsPkts1024to1518Octets =0xe , + PORT_MAC_TX_etherStatsPkts1519toMaxOctets =0xf , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_0 =0x10 , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_1 =0x11 , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_2 =0x12 , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_3 =0x13 , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_4 =0x14 , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_5 =0x15 , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_6 =0x16 , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_7 =0x17 , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_8 =0x18 , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_9 =0x19 , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_10 =0x1a , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_11 =0x1b , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_12 =0x1c , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_13 =0x1d , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_14 =0x1e , + PORT_MAC_TX_CBFCPAUSEFramesTransmitted_15 =0x1f , + PORT_MAC_TX_MACControlFramesTransmitted =0x20 , + PORT_MAC_TX_etherStatsPkts =0x21 , +PORT_MAC_TX_STATS_MAX =0x22 , +}; + +enum port_mac_fec_stats { + PORT_MAC_FEC_Correctable =0x0 , + PORT_MAC_FEC_Uncorrectable =0x1 , +PORT_MAC_FEC_STATS_MAX =0x2 , +}; + +#endif /* _FUN_PORT_H */
drivers/net/ethernet/fungible/funeth/funeth_ethtool.c new file +1182 -0
1,182 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 5/8 net/funeth: devlink support
In reply to Dimitris MichailidisThe devlink part, which is minimal at this time giving just the driver name.
--- .../ethernet/fungible/funeth/funeth_devlink.c | 40 +++++++++++++++++++ .../ethernet/fungible/funeth/funeth_devlink.h | 13 ++++++ 2 files changed, 53 insertions(+) create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_devlink.c create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_devlink.h
drivers/net/ethernet/fungible/funeth/funeth_devlink.c new file +40 -0
@@ -0,0 +1,40 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) + +#include "funeth.h" +#include "funeth_devlink.h" + +static int fun_dl_info_get (struct devlink *dl,struct devlink_info_req *req, +struct netlink_ext_ack *extack) +{ +int err; + + err =devlink_info_driver_name_put (req,KBUILD_MODNAME ); +if (err) +return err; + +return 0 ; +} + +static const struct devlink_ops fun_dl_ops = { + .info_get = fun_dl_info_get, +}; + +struct devlink *fun_devlink_alloc (struct device *dev) +{ +return devlink_alloc (&fun_dl_ops,sizeof (struct fun_ethdev ), dev); +} + +void fun_devlink_free (struct devlink *devlink) +{ +devlink_free (devlink); +} + +void fun_devlink_register (struct devlink *devlink) +{ +devlink_register (devlink); +} + +void fun_devlink_unregister (struct devlink *devlink) +{ +devlink_unregister (devlink); +}
drivers/net/ethernet/fungible/funeth/funeth_devlink.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ + +#ifndef __FUNETH_DEVLINK_H +#define __FUNETH_DEVLINK_H + +#include <net/devlink.h> + +struct devlink *fun_devlink_alloc (struct device *dev); +void fun_devlink_free (struct devlink *devlink); +void fun_devlink_register (struct devlink *devlink); +void fun_devlink_unregister (struct devlink *devlink); + +#endif /* __FUNETH_DEVLINK_H */
Signature · 1 line
2.25.1
PATCH v2 6/8 net/funeth: add the data path
In reply to Dimitris MichailidisAdd the driver's data path. Tx handles skbs, XDP, and kTLS, Rx has skbs and XDP. Also included are Rx and Tx queue creation/tear-down and tracing.
--- .../net/ethernet/fungible/funeth/funeth_rx.c | 725 ++++++++++++++++++ .../ethernet/fungible/funeth/funeth_trace.h | 117 +++ .../net/ethernet/fungible/funeth/funeth_tx.c | 701 +++++++++++++++++ .../ethernet/fungible/funeth/funeth_txrx.h | 242 ++++++ 4 files changed, 1785 insertions(+) create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_rx.c create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_trace.h create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_tx.c create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_txrx.h
drivers/net/ethernet/fungible/funeth/funeth_rx.c new file +725 -0
@@ -0,0 +1,725 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) + +#include <linux/bpf_trace.h> +#include <linux/dma-mapping.h> +#include <linux/etherdevice.h> +#include <linux/filter.h> +#include <linux/irq.h> +#include <linux/pci.h> +#include <linux/skbuff.h> +#include "funeth_txrx.h" +#include "funeth.h" +#include "fun_queue.h" + +#define CREATE_TRACE_POINTS +#include "funeth_trace.h" + +/* Given the device's max supported MTU and pages of at least 4KB a packet can +* be scattered into at most 4 buffers. +*/ +#define RX_MAX_FRAGS 4 + +/* Per packet headroom in non-XDP mode. Present only for 1-frag packets. */ +#define FUN_RX_HEADROOM (NET_SKB_PAD + NET_IP_ALIGN) + +/* We try to reuse pages for our buffers. To avoid frequent page ref writes we +* take EXTRA_PAGE_REFS references at once and then hand them out one per packet +* occupying the buffer. +*/ +#define EXTRA_PAGE_REFS 1000000 +#define MIN_PAGE_REFS 1000 + +enum { +FUN_XDP_FLUSH_REDIR =1 , +FUN_XDP_FLUSH_TX =2 , +}; + +/* See if a page is running low on refs we are holding and if so take more. */ +static inline void refresh_refs (struct funeth_rxbuf *buf) +{ +if (unlikely (buf->pg_refs <MIN_PAGE_REFS )) { + buf->pg_refs +=EXTRA_PAGE_REFS ; +page_ref_add (buf->page,EXTRA_PAGE_REFS ); + } +} + +/* Offer a buffer to the Rx buffer cache. The cache will hold the buffer if its +* page is worth retaining and there's room for it. Otherwise the page is +* unmapped and our references released. +*/ +static void cache_offer (struct funeth_rxq *q,const struct funeth_rxbuf *buf) +{ +struct funeth_rx_cache *c = &q->cache; + +if (c->prod_cnt - c->cons_cnt <= c->mask && buf->node ==numa_mem_id ()) { + c->bufs[c->prod_cnt & c->mask] = *buf; + c->prod_cnt++; + }else { +dma_unmap_page_attrs (q->dma_dev, buf->dma_addr,PAGE_SIZE , +DMA_FROM_DEVICE ,DMA_ATTR_SKIP_CPU_SYNC ); +__page_frag_cache_drain (buf->page, buf->pg_refs); + } +} + +/* Get a page from the Rx buffer cache. We only consider the next available +* page and return it if we own all its references. +*/ +static bool cache_get (struct funeth_rxq *q,struct funeth_rxbuf *rb) +{ +struct funeth_rx_cache *c = &q->cache; +struct funeth_rxbuf *buf; + +if (c->prod_cnt == c->cons_cnt) +return false;/* empty cache */ + + buf = &c->bufs[c->cons_cnt & c->mask]; +if (page_ref_count (buf->page) == buf->pg_refs) { +dma_sync_single_for_device (q->dma_dev, buf->dma_addr, +PAGE_SIZE ,DMA_FROM_DEVICE ); + *rb = *buf; + buf->page =NULL ; +refresh_refs (rb); + c->cons_cnt++; +return true; + } + +/* Page can't be reused. If the cache is full drop this page. */ +if (c->prod_cnt - c->cons_cnt > c->mask) { +dma_unmap_page_attrs (q->dma_dev, buf->dma_addr,PAGE_SIZE , +DMA_FROM_DEVICE ,DMA_ATTR_SKIP_CPU_SYNC ); +__page_frag_cache_drain (buf->page, buf->pg_refs); + buf->page =NULL ; + c->cons_cnt++; + } +return false; +} + +/* Allocate and DMA-map a page for receive. */ +static int funeth_alloc_page (struct funeth_rxq *q,struct funeth_rxbuf *rb, +int node,gfp_t gfp) +{ +struct page *p; + +if (cache_get (q, rb)) +return 0 ; + + p =__alloc_pages_node (node, gfp | __GFP_NOWARN,0 ); +if (unlikely (!p)) +return -ENOMEM ; + + rb->dma_addr =dma_map_page (q->dma_dev, p,0 ,PAGE_SIZE , +DMA_FROM_DEVICE ); +if (unlikely (dma_mapping_error (q->dma_dev, rb->dma_addr))) { +FUN_QSTAT_INC (q, rx_map_err); +__free_page (p); +return -ENOMEM ; + } + +FUN_QSTAT_INC (q, rx_page_alloc); + + rb->page = p; + rb->pg_refs =1 ; +refresh_refs (rb); + rb->node =page_is_pfmemalloc (p) ?-1 :page_to_nid (p); +return 0 ; +} + +static void funeth_free_page (struct funeth_rxq *q,struct funeth_rxbuf *rb) +{ +if (rb->page) { +dma_unmap_page (q->dma_dev, rb->dma_addr,PAGE_SIZE , +DMA_FROM_DEVICE ); +__page_frag_cache_drain (rb->page, rb->pg_refs); + rb->page =NULL ; + } +} + +/* Run the XDP program assigned to an Rx queue. +* Return %NULL if the buffer is consumed, or the virtual address of the packet +* to turn into an skb. +*/ +static void *fun_run_xdp (struct funeth_rxq *q,skb_frag_t *frags,void *buf_va, +int ref_ok,struct funeth_txq *xdp_q) +{ +struct bpf_prog *xdp_prog; +struct xdp_buff xdp; +u32 act; + +/* VA includes the headroom, frag size includes headroom + tailroom */ +xdp_init_buff (&xdp,ALIGN (skb_frag_size (frags),FUN_EPRQ_PKT_ALIGN ), + &q->xdp_rxq); +xdp_prepare_buff (&xdp, buf_va,FUN_XDP_HEADROOM ,skb_frag_size (frags) - + (FUN_RX_TAILROOM +FUN_XDP_HEADROOM ), false); + + xdp_prog =READ_ONCE (q->xdp_prog); + act =bpf_prog_run_xdp (xdp_prog, &xdp); + +switch (act) { +case XDP_PASS : +/* remove headroom, which may not be FUN_XDP_HEADROOM now */ +skb_frag_size_set (frags, xdp.data_end - xdp.data); +skb_frag_off_add (frags, xdp.data - xdp.data_hard_start); + goto pass; +case XDP_TX : +if (unlikely (!ref_ok)) + goto pass; +if (!fun_xdp_tx (xdp_q, xdp.data, xdp.data_end - xdp.data)) + goto xdp_error; +FUN_QSTAT_INC (q, xdp_tx); + q->xdp_flush |=FUN_XDP_FLUSH_TX ; +break ; +case XDP_REDIRECT : +if (unlikely (!ref_ok)) + goto pass; +if (unlikely (xdp_do_redirect (q->netdev, &xdp, xdp_prog))) + goto xdp_error; +FUN_QSTAT_INC (q, xdp_redir); + q->xdp_flush |=FUN_XDP_FLUSH_REDIR ; +break ; +default : +bpf_warn_invalid_xdp_action (act); + fallthrough; +case XDP_ABORTED : +trace_xdp_exception (q->netdev, xdp_prog, act); +xdp_error: + q->cur_buf->pg_refs++;/* return frags' page reference */ +FUN_QSTAT_INC (q, xdp_err); +break ; +case XDP_DROP : + q->cur_buf->pg_refs++; +FUN_QSTAT_INC (q, xdp_drops); +break ; + } +return NULL ; + +pass: +return xdp.data; +} + +/* A CQE contains a fixed completion structure along with optional metadata and +* even packet data. Given the start address of a CQE return the start of the +* contained fixed structure, which lies at the end. +*/ +static inline const void *cqe_to_info (const void *cqe) +{ +return cqe +FUNETH_CQE_INFO_OFFSET ; +} + +/* The inverse of cqe_to_info(). */ +static inline const void *info_to_cqe (const void *cqe_info) +{ +return cqe_info -FUNETH_CQE_INFO_OFFSET ; +} + +/* Return the type of hash provided by the device based on the L3 and L4 +* protocols it parsed for the packet. +*/ +static enum pkt_hash_types cqe_to_pkt_hash_type (u16 pkt_parse) +{ +static const enum pkt_hash_types htype_map[] = { +PKT_HASH_TYPE_NONE ,PKT_HASH_TYPE_L3 , +PKT_HASH_TYPE_NONE ,PKT_HASH_TYPE_L4 , +PKT_HASH_TYPE_NONE ,PKT_HASH_TYPE_L3 , +PKT_HASH_TYPE_NONE ,PKT_HASH_TYPE_L3 + }; +u16 key; + +/* Build the key from the TCP/UDP and IP/IPv6 bits */ + key = ((pkt_parse >>FUN_ETH_RX_CV_OL4_PROT_S ) &6 ) | + ((pkt_parse >> (FUN_ETH_RX_CV_OL3_PROT_S +1 )) &1 ); + +return htype_map[key]; +} + +/* Each received packet can be scattered across several Rx buffers or can +* share a buffer with previously received packets depending on the buffer +* and packet sizes and the room available in the most recently used buffer. +* +* The rules are: +* - If the buffer at the head of an RQ has not been used it gets (part of) the +* next incoming packet. +* - Otherwise, if the packet fully fits in the buffer's remaining space the +* packet is written there. +* - Otherwise, the packet goes into the next Rx buffer. +* +* This function returns the Rx buffer for a packet or fragment thereof of the +* given length. If it isn't @buf it either recycles or frees that buffer +* before advancing the queue to the next buffer. +* +* If called repeatedly with the remaining length of a packet it will walk +* through all the buffers containing the packet. +*/ +static struct funeth_rxbuf * +get_buf (struct funeth_rxq *q,struct funeth_rxbuf *buf,unsigned int len) +{ +if (q->buf_offset + len <=PAGE_SIZE || !q->buf_offset) +return buf;/* @buf holds (part of) the packet */ + +/* The packet occupies part of the next buffer. Move there after +* replenishing the current buffer slot either with the spare page or +* by reusing the slot's existing page. Note that if a spare page isn't +* available and the current packet occupies @buf it is a multi-frag +* packet that will be dropped leaving @buf available for reuse. +*/ +if ((page_ref_count (buf->page) == buf->pg_refs && + buf->node ==numa_mem_id ()) || !q->spare_buf.page) { +dma_sync_single_for_device (q->dma_dev, buf->dma_addr, +PAGE_SIZE ,DMA_FROM_DEVICE ); +refresh_refs (buf); + }else { +cache_offer (q, buf); + *buf = q->spare_buf; + q->spare_buf.page =NULL ; + q->rqes[q->rq_cons & q->rq_mask] = +FUN_EPRQ_RQBUF_INIT (buf->dma_addr); + } + q->buf_offset =0 ; + q->rq_cons++; +return &q->bufs[q->rq_cons & q->rq_mask]; +} + +/* Gather the page fragments making up the first Rx packet on @q. Its total +* length @tot_len includes optional head- and tail-rooms. +* +* Return 0 if the device retains ownership of at least some of the pages. +* In this case the caller may only copy the packet. +* +* A non-zero return value gives the caller permission to use references to the +* pages, e.g., attach them to skbs. Additionally, if the value is <0 at least +* one of the pages is PF_MEMALLOC. +* +* Regardless of outcome the caller is granted a reference to each of the pages. +*/ +static int fun_gather_pkt (struct funeth_rxq *q,unsigned int tot_len, +skb_frag_t *frags) +{ +struct funeth_rxbuf *buf = q->cur_buf; +unsigned int frag_len; +int ref_ok =1 ; + +for (;;) { + buf =get_buf (q, buf, tot_len); + +/* We always keep the RQ full of buffers so before we can give +* one of our pages to the stack we require that we can obtain +* a replacement page. If we can't the packet will either be +* copied or dropped so we can retain ownership of the page and +* reuse it. +*/ +if (!q->spare_buf.page && +funeth_alloc_page (q, &q->spare_buf,numa_mem_id (), +GFP_ATOMIC | __GFP_MEMALLOC)) + ref_ok =0 ; + + frag_len = min_t(unsigned int, tot_len, +PAGE_SIZE - q->buf_offset); +dma_sync_single_for_cpu (q->dma_dev, + buf->dma_addr + q->buf_offset, + frag_len,DMA_FROM_DEVICE ); + buf->pg_refs--; +if (ref_ok) + ref_ok |= buf->node; + +__skb_frag_set_page (frags, buf->page); +skb_frag_off_set (frags, q->buf_offset); +skb_frag_size_set (frags++, frag_len); + + tot_len -= frag_len; +if (!tot_len) +break ; + + q->buf_offset =PAGE_SIZE ; + } + q->buf_offset =ALIGN (q->buf_offset + frag_len,FUN_EPRQ_PKT_ALIGN ); + q->cur_buf = buf; +return ref_ok; +} + +static inline bool rx_hwtstamp_enabled (const struct net_device *dev) +{ +const struct funeth_priv *d =netdev_priv (dev); + +return d->hwtstamp_cfg.rx_filter ==HWTSTAMP_FILTER_ALL ; +} + +/* Advance the CQ pointers and phase tag to the next CQE. */ +static void advance_cq (struct funeth_rxq *q) +{ +if (unlikely (q->cq_head == q->cq_mask)) { + q->cq_head =0 ; + q->phase ^=1 ; + q->next_cqe_info =cqe_to_info (q->cqes); + }else { + q->cq_head++; + q->next_cqe_info +=FUNETH_CQE_SIZE ; + } +prefetch (q->next_cqe_info); +} + +/* Process the packet represented by the head CQE of @q. Gather the packet's +* fragments, run it through the optional XDP program, and if needed construct +* an skb and pass it to the stack. +*/ +static void fun_handle_cqe_pkt (struct funeth_rxq *q,struct funeth_txq *xdp_q) +{ +const struct fun_eth_cqe *rxreq =info_to_cqe (q->next_cqe_info); +unsigned int i, tot_len, pkt_len =be32_to_cpu (rxreq->pkt_len); +struct net_device *ndev = q->netdev; +skb_frag_t frags[RX_MAX_FRAGS ]; +struct skb_shared_info *si; +gro_result_t gro_res; +struct sk_buff *skb; +int ref_ok; +void *va; +u16 cv; + +u64_stats_update_begin (&q->syncp); + q->stats.rx_pkts++; + q->stats.rx_bytes += pkt_len; +u64_stats_update_end (&q->syncp); + +advance_cq (q); + +/* account for head- and tail-room, present only for 1-buffer packets */ + tot_len = pkt_len + q->extraroom; +if (unlikely (tot_len >PAGE_SIZE )) + tot_len = pkt_len; + + ref_ok =fun_gather_pkt (q, tot_len, frags); + va =skb_frag_address (frags); +if (xdp_q) { + va =fun_run_xdp (q, frags, va, ref_ok, xdp_q); +if (!va) +return ; + } +if (unlikely (!ref_ok)) + goto no_mem; + +if (likely (rxreq->headroom ==cpu_to_be16 (FUN_RX_HEADROOM ))) { +prefetch (va +FUN_RX_HEADROOM ); + skb =build_skb (va,ALIGN (tot_len,FUN_EPRQ_PKT_ALIGN )); +if (unlikely (!skb)) + goto no_mem; + +skb_reserve (skb,FUN_RX_HEADROOM ); +__skb_put (skb, pkt_len); + skb->protocol =eth_type_trans (skb, ndev); + }else { +prefetch (va); + skb =napi_get_frags (q->napi); +if (unlikely (!skb)) + goto no_mem; + +if (ref_ok <0 ) + skb->pfmemalloc =1 ; + + si =skb_shinfo (skb); + si->nr_frags = rxreq->nsgl; +for (i =0 ; i < si->nr_frags; i++) + si->frags[i] = frags[i]; + + skb->len = pkt_len; + skb->data_len = pkt_len; + skb->truesize +=round_up (pkt_len,FUN_EPRQ_PKT_ALIGN ); + } + +skb_record_rx_queue (skb, q->qidx); + cv =be16_to_cpu (rxreq->pkt_cv); +if (likely ((q->netdev->features &NETIF_F_RXHASH ) && rxreq->hash)) +skb_set_hash (skb,be32_to_cpu (rxreq->hash), +cqe_to_pkt_hash_type (cv)); +if (likely ((q->netdev->features &NETIF_F_RXCSUM ) && rxreq->csum)) { +FUN_QSTAT_INC (q, rx_cso); + skb->ip_summed =CHECKSUM_UNNECESSARY ; + skb->csum_level =be16_to_cpu (rxreq->csum) -1 ; + } +if (unlikely (rx_hwtstamp_enabled (q->netdev))) +skb_hwtstamps (skb)->hwtstamp =be64_to_cpu (rxreq->timestamp); + +trace_funeth_rx (q, rxreq->nsgl, pkt_len, skb->hash, cv); + + gro_res = skb->data_len ?napi_gro_frags (q->napi) : +napi_gro_receive (q->napi, skb); +if (gro_res ==GRO_MERGED || gro_res ==GRO_MERGED_FREE ) +FUN_QSTAT_INC (q, gro_merged); +else if (gro_res ==GRO_HELD ) +FUN_QSTAT_INC (q, gro_pkts); +return ; + +no_mem: +FUN_QSTAT_INC (q, rx_mem_drops); + +/* Release the references we've been granted for the frag pages. +* We return the ref of the last frag and free the rest. +*/ + q->cur_buf->pg_refs++; +for (i =0 ; i < rxreq->nsgl -1 ; i++) +__free_page (skb_frag_page (frags + i)); +} + +/* Return 0 if the phase tag of the CQE at the CQ's head matches expectations +* indicating the CQE is new. +*/ +static inline u16 cqe_phase_mismatch (const struct fun_cqe_info *ci,u16 phase) +{ +u16 sf_p =be16_to_cpu (ci->sf_p); + +return (sf_p &1 ) ^ phase; +} + +/* Walk through a CQ identifying and processing fresh CQEs up to the given +* budget. Return the remaining budget. +*/ +static int fun_process_cqes (struct funeth_rxq *q,int budget) +{ +struct funeth_txq *xdp_q =NULL ; + +if (READ_ONCE (q->xdp_prog)) { +struct funeth_priv *fp =netdev_priv (q->netdev); + + xdp_q = fp->xdpqs[smp_processor_id ()]; + } + +while (budget && !cqe_phase_mismatch (q->next_cqe_info, q->phase)) { +/* access other descriptor fields after the phase check */ +dma_rmb (); + +fun_handle_cqe_pkt (q, xdp_q); + budget--; + } + +if (unlikely (q->xdp_flush)) { +if (q->xdp_flush &FUN_XDP_FLUSH_TX ) +fun_txq_wr_db (xdp_q); +if (q->xdp_flush &FUN_XDP_FLUSH_REDIR ) +xdp_do_flush (); + q->xdp_flush =0 ; + } + +return budget; +} + +/* NAPI handler for Rx queues. Calls the CQE processing loop and writes RQ/CQ +* doorbells as needed. +*/ +int fun_rxq_napi_poll (struct napi_struct *napi,int budget) +{ + struct fun_irq *irq = container_of(napi, struct fun_irq, napi); +struct funeth_rxq *q = irq->rxq; +int work_done = budget -fun_process_cqes (q, budget); +u32 cq_db_val = q->cq_head; + +if (unlikely (work_done >= budget)) +FUN_QSTAT_INC (q, rx_budget); +else if (napi_complete_done (napi, work_done)) + cq_db_val |= q->irq_db_val; + +/* check whether to post new Rx buffers */ +if (q->rq_cons - q->rq_cons_db >= q->rq_db_thres) { +u64_stats_update_begin (&q->syncp); + q->stats.rx_bufs += q->rq_cons - q->rq_cons_db; +u64_stats_update_end (&q->syncp); + q->rq_cons_db = q->rq_cons; +writel ((q->rq_cons -1 ) & q->rq_mask, q->rq_db); + } + +writel (cq_db_val, q->cq_db); +return work_done; +} + +/* Free the Rx buffers of an Rx queue. */ +static void fun_rxq_free_bufs (struct funeth_rxq *q) +{ +struct funeth_rxbuf *b = q->bufs; +unsigned int i; + +for (i =0 ; i <= q->rq_mask; i++, b++) +funeth_free_page (q, b); + +funeth_free_page (q, &q->spare_buf); + q->cur_buf =NULL ; +} + +/* Initially provision an Rx queue with Rx buffers. */ +static int fun_rxq_alloc_bufs (struct funeth_rxq *q,int node) +{ +struct funeth_rxbuf *b = q->bufs; +unsigned int i; + +for (i =0 ; i <= q->rq_mask; i++, b++) { +if (funeth_alloc_page (q, b, node,GFP_KERNEL )) { +fun_rxq_free_bufs (q); +return -ENOMEM ; + } + q->rqes[i] =FUN_EPRQ_RQBUF_INIT (b->dma_addr); + } + q->cur_buf = q->bufs; +return 0 ; +} + +/* Initialize a used-buffer cache of the given depth. */ +static int fun_rxq_init_cache (struct funeth_rx_cache *c,unsigned int depth, +int node) +{ + c->mask = depth -1 ; + c->bufs =kvzalloc_node (depth *sizeof (*c->bufs),GFP_KERNEL , node); +return c->bufs ?0 : -ENOMEM ; +} + +/* Deallocate an Rx queue's used-buffer cache and its contents. */ +static void fun_rxq_free_cache (struct funeth_rxq *q) +{ +struct funeth_rxbuf *b = q->cache.bufs; +unsigned int i; + +for (i =0 ; i <= q->cache.mask; i++, b++) +funeth_free_page (q, b); + +kvfree (q->cache.bufs); + q->cache.bufs =NULL ; +} + +/* Create an Rx queue, allocating all the host and device resources needed. */ +struct funeth_rxq *funeth_rxq_create (struct net_device *dev,unsigned int qidx, +unsigned int ncqe,unsigned int nrqe, +struct fun_irq *irq) +{ +struct funeth_priv *fp =netdev_priv (dev); +unsigned int irq_idx = irq->irq_idx; +unsigned int headroom, tailroom; +struct funeth_rxq *q; +int err = -ENOMEM ; +int numa_node; + + numa_node =fun_irq_node (irq); + q =kzalloc_node (sizeof (*q),GFP_KERNEL , numa_node); +if (!q) + goto err; + + q->netdev = dev; + q->napi = &irq->napi; + q->dma_dev = &fp->pdev->dev; + q->cq_mask = ncqe -1 ; + q->rq_mask = nrqe -1 ; + q->qidx = qidx; + + q->rqes =fun_alloc_ring_mem (q->dma_dev, nrqe,sizeof (*q->rqes), +sizeof (*q->bufs), false, numa_node, + &q->rq_dma_addr, (void **)&q->bufs,NULL ); +if (!q->rqes) + goto free_q; + + q->cqes =fun_alloc_ring_mem (q->dma_dev, ncqe,FUNETH_CQE_SIZE ,0 , + false, numa_node, &q->cq_dma_addr,NULL , +NULL ); +if (!q->cqes) + goto free_rqes; + + err =fun_rxq_init_cache (&q->cache, nrqe, numa_node); +if (err) + goto free_cqes; + + q->xdp_prog = fp->xdp_prog; + headroom = fp->xdp_prog ?FUN_XDP_HEADROOM :FUN_RX_HEADROOM ; + tailroom =FUN_RX_TAILROOM ; + q->extraroom = headroom + tailroom; + + err =fun_sq_create (fp->fdev,FUN_ADMIN_RES_CREATE_FLAG_ALLOCATOR | +FUN_ADMIN_EPSQ_CREATE_FLAG_RQ ,0 , +FUN_HCI_ID_INVALID ,0 , nrqe, q->rq_dma_addr,0 ,0 , +0 ,0 , fp->fdev->kern_end_qid,PAGE_SHIFT , + &q->hw_sqid, &q->rq_db); +if (err) + goto free_cache; + + err =fun_cq_create (fp->fdev,FUN_ADMIN_RES_CREATE_FLAG_ALLOCATOR | +FUN_ADMIN_EPCQ_CREATE_FLAG_RQ ,0 , + q->hw_sqid,ilog2 (FUNETH_CQE_SIZE ), ncqe, + q->cq_dma_addr, headroom, tailroom,0 ,0 , irq_idx, +0 , fp->fdev->kern_end_qid, &q->hw_cqid, &q->cq_db); +if (err) + goto free_rq; + + err =fun_rxq_alloc_bufs (q, numa_node); +if (err) + goto free_cq; + + q->phase =1 ; + q->irq_idx = irq_idx; + q->rq_db_thres = nrqe /4 ; + q->next_cqe_info =cqe_to_info (q->cqes); + q->stats.rx_bufs = q->rq_mask; +u64_stats_init (&q->syncp); + + err =xdp_rxq_info_reg (&q->xdp_rxq, dev, qidx, irq->napi.napi_id); +if (err) + goto free_bufs; + + err =xdp_rxq_info_reg_mem_model (&q->xdp_rxq,MEM_TYPE_PAGE_SHARED , +NULL ); +if (err) + goto xdp_unreg; + + irq->rxq = q; +writel (q->rq_mask, q->rq_db); + +netif_info (fp, ifup, dev, +"Rx queue %u, depth %u/%u, HW qid %u/%u, IRQ idx %u, node %d, headroom %u\n" , + qidx, ncqe, nrqe, q->hw_cqid, q->hw_sqid, irq_idx, + numa_node, headroom); +return q; + +xdp_unreg: +xdp_rxq_info_unreg (&q->xdp_rxq); +free_bufs: +fun_rxq_free_bufs (q); +free_cq: +fun_destroy_cq (fp->fdev, q->hw_cqid); +free_rq: +fun_destroy_sq (fp->fdev, q->hw_sqid); +free_cache: +fun_rxq_free_cache (q); +free_cqes: +dma_free_coherent (q->dma_dev, ncqe *FUNETH_CQE_SIZE , q->cqes, + q->cq_dma_addr); +free_rqes: +fun_free_ring_mem (q->dma_dev, nrqe,sizeof (*q->rqes), false, q->rqes, + q->rq_dma_addr, q->bufs); +free_q: +kfree (q); +err: +netdev_err (dev,"Failed to allocate Rx queue %u, error %d\n" , qidx, + err); +return ERR_PTR (err); +} + +/* Destroy and free an Rx queue. */ +int funeth_rxq_free (struct funeth_rxq *q) +{ +struct funeth_priv *fp =netdev_priv (q->netdev); +int err, err2; + + err =fun_destroy_sq (fp->fdev, q->hw_sqid); + err2 =fun_destroy_cq (fp->fdev, q->hw_cqid); +if (!err) + err = err2; + +fun_rxq_free_cache (q); +fun_rxq_free_bufs (q); +xdp_rxq_info_unreg (&q->xdp_rxq); +fun_free_ring_mem (q->dma_dev, q->rq_mask +1 ,sizeof (*q->rqes), false, + q->rqes, q->rq_dma_addr, q->bufs); +dma_free_coherent (q->dma_dev, (q->cq_mask +1 ) *FUNETH_CQE_SIZE , + q->cqes, q->cq_dma_addr); + +/* Before freeing the queue transfer key counters to the device. */ + fp->rx_packets += q->stats.rx_pkts; + fp->rx_bytes += q->stats.rx_bytes; + fp->rx_dropped += q->stats.rx_map_err + q->stats.rx_mem_drops; + +netif_info (fp, ifdown, q->netdev, +"Freeing Rx queue %u (id %u/%u), IRQ %u, err %d\n" , + q->qidx, q->hw_cqid, q->hw_sqid, q->irq_idx, err); +kfree (q); +return err; +}
drivers/net/ethernet/fungible/funeth/funeth_trace.h new file +117 -0
117 lines not on this page · raw message
drivers/net/ethernet/fungible/funeth/funeth_tx.c new file +701 -0
701 lines not on this page · raw message
drivers/net/ethernet/fungible/funeth/funeth_txrx.h new file +242 -0
242 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH net-next v2 6/8] net/funeth: add the data path
drivers/net/ethernet/fungible/funeth/funeth_rx.c line 44
Quoted 10 lines
+++
b/drivers/net/ethernet/fungible/funeth/funeth_rx.cdrivers/net/ethernet/fungible/funeth/funeth_rx.c new file +8
-0+/* See if a page is running low on refs we are holding and if so take more. */ +static inline void refresh_refs (struct funeth_rxbuf *buf) +{ +if (unlikely (buf->pg_refs <MIN_PAGE_REFS )) { + buf->pg_refs +=EXTRA_PAGE_REFS ; +page_ref_add (buf->page,EXTRA_PAGE_REFS ); + } +}
No inline functions in C files please. Let the compiler decide. Please check for this in the whole driver.
Quoted 4 lines
drivers/net/ethernet/fungible/funeth/funeth_rx.c new file +4
-0+/* A CQE contains a fixed completion structure along with optional metadata and +* even packet data. Given the start address of a CQE return the start of the +* contained fixed structure, which lies at the end. +*/
drivers/net/ethernet/fungible/funeth/funeth_rx.c line 212
Quoted 10 lines
drivers/net/ethernet/fungible/funeth/funeth_rx.c new file +10
-0+static inline const void *cqe_to_info (const void *cqe) +{ +return cqe +FUNETH_CQE_INFO_OFFSET ; +} + +/* The inverse of cqe_to_info(). */ +static inline const void *info_to_cqe (const void *cqe_info) +{ +return cqe_info -FUNETH_CQE_INFO_OFFSET ; +}
This looks pretty brittle. Can you define a struct cqe, so avoid all this arithmetic on void * pointers?
drivers/net/ethernet/fungible/funeth/funeth_tx.c line 127
Quoted 5 lines
drivers/net/ethernet/fungible/funeth/funeth_tx.c new file +5
-0+static unsigned int write_pkt_desc (struct sk_buff *skb,struct funeth_txq *q, +unsigned int tls_len) +{ +unsigned int idx = q->prod_cnt & q->mask; +struct fun_eth_tx_req *req =fun_tx_desc_addr (q, idx);
You need to move the assignment into the body to keep with reverse Christmas tree.
drivers/net/ethernet/fungible/funeth/funeth_tx.c line 238
Quoted 7 lines
drivers/net/ethernet/fungible/funeth/funeth_tx.c new file +7
-0+if (txq_to_end (q, gle) ==0 ) { + gle = (struct fun_dataop_gl *)q->desc; +for ( ; i < ngle; i++, gle++) +fun_dataop_gl_init (gle,0 ,0 , lens[i], addrs[i]); + } + +#ifdef CONFIG_TLS_DEVICE
If possible, use if (IS_ENABLED(TLS_DEVICE)), not #ifdef. It will give you better compile testing, if it works.
Quoted 27 lines
drivers/net/ethernet/fungible/funeth/funeth_tx.c new file +26
-0+if (unlikely (tls_len)) { +struct fun_eth_tls *tls = (struct fun_eth_tls *)gle; +struct fun_ktls_tx_ctx *tls_ctx; + + req->len8 +=FUNETH_TLS_SZ /8 ; + req->flags =cpu_to_be16 (FUN_ETH_TX_TLS ); + + tls_ctx =tls_driver_ctx (skb->sk,TLS_OFFLOAD_CTX_DIR_TX ); + tls->tlsid = tls_ctx->tlsid; + tls_ctx->next_seq += tls_len; + +u64_stats_update_begin (&q->syncp); + q->stats.tx_tls_bytes += tls_len; + q->stats.tx_tls_pkts +=1 + extra_pkts; +u64_stats_update_end (&q->syncp); + } +#endif +/* Create a Tx queue, allocating all the host and device resources needed. */ +struct funeth_txq *funeth_txq_create (struct net_device *dev,unsigned int qidx, +unsigned int ndesc,struct fun_irq *irq) +{ +struct funeth_priv *fp =netdev_priv (dev); +unsigned int ethid = fp->ethid_start + qidx; +int numa_node, err = -ENOMEM ; +struct funeth_txq *q; +const char *qtype;
...
drivers/net/ethernet/fungible/funeth/funeth_tx.c line 655
Quoted 3 lines
drivers/net/ethernet/fungible/funeth/funeth_tx.c new file +3
-0+netif_info (fp, ifup, dev, +"%s queue %u, depth %u, HW qid %u, IRQ idx %u, node %d\n" , + qtype, qidx, ndesc, q->hw_qid, q->irq_idx, numa_node);
Probably should be _dbg(). We try not to spam the kernel log.
Quoted 7 lines
drivers/net/ethernet/fungible/funeth/funeth_txrx.h new file +7
-0+struct funeth_txq_stats {/* per Tx queue SW counters */ +u64 tx_pkts;/* # of Tx packets */ +u64 tx_bytes;/* total bytes of Tx packets */ +u64 tx_cso;/* # of packets with checksum offload */ +u64 tx_tso;/* # of TSO super-packets */ +u64 tx_more;/* # of DBs elided due to xmit_more */ +u64 tx_nstops;/* # of times the queue has stopped */
drivers/net/ethernet/fungible/funeth/funeth_txrx.h line 78
Quoted 10 lines
drivers/net/ethernet/fungible/funeth/funeth_txrx.h new file +10
-0+u64 tx_nrestarts;/* # of times the queue has restarted */ +u64 tx_map_err;/* # of packets dropped due to DMA mapping errors */ +u64 tx_len_err;/* # of packets dropped due to unsupported length */ +u64 tx_xdp_full;/* # of XDP packets that could not be enqueued */ +#ifdef CONFIG_TLS_DEVICE +u64 tx_tls_pkts;/* # of Tx TLS packets offloaded to HW */ +u64 tx_tls_bytes;/* Tx bytes of HW-handled TLS payload */ +u64 tx_tls_fallback;/* attempted Tx TLS offloads punted to SW */ +u64 tx_tls_drops;/* attempted Tx TLS offloads dropped */ +#endif
You might want to think about this, and kAPI stability. I assume it implies a different number of statistics are returned by ethtool -S, depending on how the driver is built. That could be surprising for user space. It might be better to always have the statistics, and just return 0 when TLS is not available.
Andrew
Re: [PATCH net-next v2 6/8] net/funeth: add the data path
Quoted 14 lines · Andrew Lunn
drivers/net/ethernet/fungible/funeth/funeth_rx.c line 44
Quoted 11 lines
+++
b/drivers/net/ethernet/fungible/funeth/funeth_rx.cdrivers/net/ethernet/fungible/funeth/funeth_rx.c new file +8
-0+/* See if a page is running low on refs we are holding and if so take more. */ +static inline void refresh_refs (struct funeth_rxbuf *buf) +{ +if (unlikely (buf->pg_refs <MIN_PAGE_REFS )) { + buf->pg_refs +=EXTRA_PAGE_REFS ; +page_ref_add (buf->page,EXTRA_PAGE_REFS ); + } +}No inline functions in C files please. Let the compiler decide. Please check for this in the whole driver.
Removed.
Quoted 10 lines
Quoted 10 lines
drivers/net/ethernet/fungible/funeth/funeth_rx.c new file +9
-0+/* A CQE contains a fixed completion structure along with optional metadata and +* even packet data. Given the start address of a CQE return the start of the +* contained fixed structure, which lies at the end. +*/ +static inline const void *cqe_to_info (const void *cqe) +{ +return cqe +FUNETH_CQE_INFO_OFFSET ; +} +
Quoted 8 lines
drivers/net/ethernet/fungible/funeth/funeth_rx.c line 212
Quoted 5 lines
drivers/net/ethernet/fungible/funeth/funeth_rx.c new file +5
-0+/* The inverse of cqe_to_info(). */ +static inline const void *info_to_cqe (const void *cqe_info) +{ +return cqe_info -FUNETH_CQE_INFO_OFFSET ; +}This looks pretty brittle. Can you define a struct cqe, so avoid all this arithmetic on void * pointers?
The top and bottom parts of a CQE are defined by FW (fun_eth_cqe and fun_cqe_info) and there's a variable number of unused bytes in the middle determined by the driver's choice of descriptor size. The driver would need to define a struct with FUNETH_CQE_INFO_OFFSET - sizeof(fun_cqe_info) space in the middle. Certainly doable but from a quick prototyping it looks uglier to me.
This is for these queues that have a compile-time descriptor size and known top part. The funcore library module does similar info<->cqe conversions in a somewhat different form but because it's a library it doesn't know the desc size at compile time and wouldn't be able to define the structure. The two modules would deviate in how they handle this while today their difference is one uses a compile-time offset and the other a run-time one.
Quoted 8 lines
drivers/net/ethernet/fungible/funeth/funeth_tx.c line 127
Quoted 5 lines
drivers/net/ethernet/fungible/funeth/funeth_tx.c new file +5
-0+static unsigned int write_pkt_desc (struct sk_buff *skb,struct funeth_txq *q, +unsigned int tls_len) +{ +unsigned int idx = q->prod_cnt & q->mask; +struct fun_eth_tx_req *req =fun_tx_desc_addr (q, idx);You need to move the assignment into the body to keep with reverse Christmas tree.
Done
Quoted 10 lines
drivers/net/ethernet/fungible/funeth/funeth_tx.c line 238
Quoted 7 lines
drivers/net/ethernet/fungible/funeth/funeth_tx.c new file +7
-0+if (txq_to_end (q, gle) ==0 ) { + gle = (struct fun_dataop_gl *)q->desc; +for ( ; i < ngle; i++, gle++) +fun_dataop_gl_init (gle,0 ,0 , lens[i], addrs[i]); + } + +#ifdef CONFIG_TLS_DEVICE If possible, use if (
IS_ENABLED(TLS_DEVICE)), not #ifdef. It will give you better compile testing, if it works.
Done
Quoted 30 lines
Quoted 27 lines
drivers/net/ethernet/fungible/funeth/funeth_tx.c new file +26
-0+if (unlikely (tls_len)) { +struct fun_eth_tls *tls = (struct fun_eth_tls *)gle; +struct fun_ktls_tx_ctx *tls_ctx; + + req->len8 +=FUNETH_TLS_SZ /8 ; + req->flags =cpu_to_be16 (FUN_ETH_TX_TLS ); + + tls_ctx =tls_driver_ctx (skb->sk,TLS_OFFLOAD_CTX_DIR_TX ); + tls->tlsid = tls_ctx->tlsid; + tls_ctx->next_seq += tls_len; + +u64_stats_update_begin (&q->syncp); + q->stats.tx_tls_bytes += tls_len; + q->stats.tx_tls_pkts +=1 + extra_pkts; +u64_stats_update_end (&q->syncp); + } +#endif +/* Create a Tx queue, allocating all the host and device resources needed. */ +struct funeth_txq *funeth_txq_create (struct net_device *dev,unsigned int qidx, +unsigned int ndesc,struct fun_irq *irq) +{ +struct funeth_priv *fp =netdev_priv (dev); +unsigned int ethid = fp->ethid_start + qidx; +int numa_node, err = -ENOMEM ; +struct funeth_txq *q; +const char *qtype;...
Quoted 5 lines
drivers/net/ethernet/fungible/funeth/funeth_tx.c line 655
Quoted 3 lines
drivers/net/ethernet/fungible/funeth/funeth_tx.c new file +3
-0+netif_info (fp, ifup, dev, +"%s queue %u, depth %u, HW qid %u, IRQ idx %u, node %d\n" , + qtype, qidx, ndesc, q->hw_qid, q->irq_idx, numa_node);Probably should be
_dbg(). We try not to spam the kernel log.
One needs to set msglvl in ethtool to get this. msglvl defaults to 0 so it doesn't log if not requested.
Quoted 15 lines
Quoted 15 lines
drivers/net/ethernet/fungible/funeth/funeth_txrx.h new file +15
-0+struct funeth_txq_stats {/* per Tx queue SW counters */ +u64 tx_pkts;/* # of Tx packets */ +u64 tx_bytes;/* total bytes of Tx packets */ +u64 tx_cso;/* # of packets with checksum offload */ +u64 tx_tso;/* # of TSO super-packets */ +u64 tx_more;/* # of DBs elided due to xmit_more */ +u64 tx_nstops;/* # of times the queue has stopped */ +u64 tx_nrestarts;/* # of times the queue has restarted */ +u64 tx_map_err;/* # of packets dropped due to DMA mapping errors */ +u64 tx_len_err;/* # of packets dropped due to unsupported length */ +u64 tx_xdp_full;/* # of XDP packets that could not be enqueued */ +#ifdef CONFIG_TLS_DEVICE +u64 tx_tls_pkts;/* # of Tx TLS packets offloaded to HW */ +u64 tx_tls_bytes;/* Tx bytes of HW-handled TLS payload */ +u64 tx_tls_fallback;/* attempted Tx TLS offloads punted to SW */
Quoted 8 lines
drivers/net/ethernet/fungible/funeth/funeth_txrx.h line 78
Quoted 2 lines
drivers/net/ethernet/fungible/funeth/funeth_txrx.h new file +2
-0+u64 tx_tls_drops;/* attempted Tx TLS offloads dropped */ +#endif You might want to think about this, and kAPI stability. I assume it implies a different number of statistics are returned by ethtool -S, depending on how the driver is built. That could be surprising for user space. It might be better to always have the statistics, and just return 0 when TLS is not available.
Yes, ethtool -S has them based on config. Perfectly happy to always have them. Will change it.
Quoted 2 lines
Andrew
PATCH v2 7/8 net/funeth: add kTLS TX control part
In reply to Dimitris MichailidisThis provides the control pieces for kTLS Tx offload, implementinng the offload operations.
--- .../ethernet/fungible/funeth/funeth_ktls.c | 181 ++++++++++++++++++ .../ethernet/fungible/funeth/funeth_ktls.h | 33 ++++ 2 files changed, 214 insertions(+) create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_ktls.c create mode 100644 drivers/net/ethernet/fungible/funeth/funeth_ktls.h
drivers/net/ethernet/fungible/funeth/funeth_ktls.c new file +181 -0
@@ -0,0 +1,181 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) + +#include "funeth.h" +#include "funeth_ktls.h" + +static int fun_admin_ktls_create (struct funeth_priv *fp,unsigned int id) +{ +struct fun_admin_ktls_create_req req = { + .common =FUN_ADMIN_REQ_COMMON_INIT2 (FUN_ADMIN_OP_KTLS , +sizeof (req)), + .subop =FUN_ADMIN_SUBOP_CREATE , + .id =cpu_to_be32 (id), + }; + +return fun_submit_admin_sync_cmd (fp->fdev, &req.common,NULL ,0 ,0 ); +} + +static int fun_ktls_add (struct net_device *netdev,struct sock *sk, +enum tls_offload_ctx_dir direction, +struct tls_crypto_info *crypto_info, +u32 start_offload_tcp_sn) +{ +struct funeth_priv *fp =netdev_priv (netdev); +struct fun_admin_ktls_modify_req req = { + .common =FUN_ADMIN_REQ_COMMON_INIT2 (FUN_ADMIN_OP_KTLS , +sizeof (req)), + .subop =FUN_ADMIN_SUBOP_MODIFY , + .id =cpu_to_be32 (fp->ktls_id), + .tcp_seq =cpu_to_be32 (start_offload_tcp_sn), + }; +struct fun_admin_ktls_modify_rsp rsp; +struct fun_ktls_tx_ctx *tx_ctx; +int rc; + +if (direction !=TLS_OFFLOAD_CTX_DIR_TX ) +return -EOPNOTSUPP ; + +if (crypto_info->version ==TLS_1_2_VERSION ) + req.version =FUN_KTLS_TLSV2 ; +else if (crypto_info->version ==TLS_1_3_VERSION ) + req.version =FUN_KTLS_TLSV3 ; +else +return -EOPNOTSUPP ; + +switch (crypto_info->cipher_type) { +case TLS_CIPHER_AES_GCM_128 : { +struct tls12_crypto_info_aes_gcm_128 *c = (void *)crypto_info; + + req.cipher =FUN_KTLS_CIPHER_AES_GCM_128 ; +memcpy (req.key, c->key,sizeof (c->key)); +memcpy (req.iv, c->iv,sizeof (c->iv)); +memcpy (req.salt, c->salt,sizeof (c->salt)); +memcpy (req.record_seq, c->rec_seq,sizeof (c->rec_seq)); +break ; + } + +case TLS_CIPHER_AES_GCM_256 : { +struct tls12_crypto_info_aes_gcm_256 *c = (void *)crypto_info; + + req.cipher =FUN_KTLS_CIPHER_AES_GCM_256 ; +memcpy (req.key, c->key,sizeof (c->key)); +memcpy (req.iv, c->iv,sizeof (c->iv)); +memcpy (req.salt, c->salt,sizeof (c->salt)); +memcpy (req.record_seq, c->rec_seq,sizeof (c->rec_seq)); +break ; + } + +case TLS_CIPHER_CHACHA20_POLY1305 : { +struct tls12_crypto_info_chacha20_poly1305 *c; + + c = (void *)crypto_info; + req.cipher =FUN_KTLS_CIPHER_CHACHA20_POLY1305 ; +memcpy (req.key, c->key,sizeof (c->key)); +memcpy (req.iv, c->iv,sizeof (c->iv)); +memcpy (req.salt, c->salt,sizeof (c->salt)); +memcpy (req.record_seq, c->rec_seq,sizeof (c->rec_seq)); +break ; + } + +default : +return -EOPNOTSUPP ; + } + + rc =fun_submit_admin_sync_cmd (fp->fdev, &req.common, &rsp, +sizeof (rsp),0 ); +memzero_explicit (&req,sizeof (req)); +if (rc) +return rc; + + tx_ctx =tls_driver_ctx (sk, direction); + tx_ctx->tlsid = rsp.tlsid; + tx_ctx->next_seq = start_offload_tcp_sn; +atomic64_inc (&fp->tx_tls_add); +return 0 ; +} + +static void fun_ktls_del (struct net_device *netdev, +struct tls_context *tls_ctx, +enum tls_offload_ctx_dir direction) +{ +struct funeth_priv *fp =netdev_priv (netdev); +struct fun_admin_ktls_modify_req req; +struct fun_ktls_tx_ctx *tx_ctx; + +if (direction !=TLS_OFFLOAD_CTX_DIR_TX ) +return ; + + tx_ctx =__tls_driver_ctx (tls_ctx, direction); + + req.common =FUN_ADMIN_REQ_COMMON_INIT2 (FUN_ADMIN_OP_KTLS , + offsetof(struct fun_admin_ktls_modify_req , tcp_seq)); + req.subop =FUN_ADMIN_SUBOP_MODIFY ; + req.flags =cpu_to_be16 (FUN_KTLS_MODIFY_REMOVE ); + req.id =cpu_to_be32 (fp->ktls_id); + req.tlsid = tx_ctx->tlsid; + +fun_submit_admin_sync_cmd (fp->fdev, &req.common,NULL ,0 ,0 ); +atomic64_inc (&fp->tx_tls_del); +} + +static int fun_ktls_resync (struct net_device *netdev,struct sock *sk,u32 seq, +u8 *rcd_sn,enum tls_offload_ctx_dir direction) +{ +struct funeth_priv *fp =netdev_priv (netdev); +struct fun_admin_ktls_modify_req req; +struct fun_ktls_tx_ctx *tx_ctx; +int rc; + +if (direction !=TLS_OFFLOAD_CTX_DIR_TX ) +return -EOPNOTSUPP ; + + tx_ctx =tls_driver_ctx (sk, direction); + + req.common =FUN_ADMIN_REQ_COMMON_INIT2 (FUN_ADMIN_OP_KTLS , + offsetof(struct fun_admin_ktls_modify_req , key)); + req.subop =FUN_ADMIN_SUBOP_MODIFY ; + req.flags =0 ; + req.id =cpu_to_be32 (fp->ktls_id); + req.tlsid = tx_ctx->tlsid; + req.tcp_seq =cpu_to_be32 (seq); + req.version =0 ; + req.cipher =0 ; +memcpy (req.record_seq, rcd_sn,sizeof (req.record_seq)); + +atomic64_inc (&fp->tx_tls_resync); + rc =fun_submit_admin_sync_cmd (fp->fdev, &req.common,NULL ,0 ,0 ); +if (!rc) + tx_ctx->next_seq = seq; +return rc; +} + +static const struct tlsdev_ops fun_ktls_ops = { + .tls_dev_add = fun_ktls_add, + .tls_dev_del = fun_ktls_del, + .tls_dev_resync = fun_ktls_resync, +}; + +int fun_ktls_init (struct net_device *netdev) +{ +struct funeth_priv *fp =netdev_priv (netdev); +int rc; + + rc =fun_admin_ktls_create (fp, netdev->dev_port); +if (rc) +return rc; + + fp->ktls_id = netdev->dev_port; + netdev->tlsdev_ops = &fun_ktls_ops; + netdev->hw_features |=NETIF_F_HW_TLS_TX ; + netdev->features |=NETIF_F_HW_TLS_TX ; +return 0 ; +} + +void fun_ktls_cleanup (struct funeth_priv *fp) +{ +if (fp->ktls_id ==FUN_HCI_ID_INVALID ) +return ; + +fun_res_destroy (fp->fdev,FUN_ADMIN_OP_KTLS ,0 , fp->ktls_id); + fp->ktls_id =FUN_HCI_ID_INVALID ; +}
drivers/net/ethernet/fungible/funeth/funeth_ktls.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ + +#ifndef _FUN_KTLS_H +#define _FUN_KTLS_H + +struct net_device ; +struct funeth_priv ; + +#ifdef CONFIG_TLS_DEVICE +#include <net/tls.h> + +struct fun_ktls_tx_ctx { +__be64 tlsid; +u32 next_seq; +}; + +int fun_ktls_init (struct net_device *netdev); +void fun_ktls_cleanup (struct funeth_priv *fp); + +#else +#include <linux/errno.h> + +static inline int fun_ktls_init (struct net_device *netdev) +{ +return -ENOTSUPP ; +} + +static inline void fun_ktls_cleanup (struct funeth_priv *fp) +{ +} +#endif + +#endif /* _FUN_KTLS_H */
Signature · 1 line
2.25.1
PATCH v2 8/8 net/fungible: Kconfig, Makefiles, and MAINTAINERS
In reply to Dimitris MichailidisHook up the new driver to configuration and build.
--- MAINTAINERS | 6 +++++ drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/fungible/Kconfig | 27 +++++++++++++++++++ drivers/net/ethernet/fungible/Makefile | 7 +++++ drivers/net/ethernet/fungible/funeth/Kconfig | 17 ++++++++++++ drivers/net/ethernet/fungible/funeth/Makefile | 10 +++++++ 7 files changed, 69 insertions(+) create mode 100644 drivers/net/ethernet/fungible/Kconfig create mode 100644 drivers/net/ethernet/fungible/Makefile create mode 100644 drivers/net/ethernet/fungible/funeth/Kconfig create mode 100644 drivers/net/ethernet/fungible/funeth/Makefile
MAINTAINERS +6 -0
@@ -7853,6 +7853,12 @@ L: [email protected] S: Maintained F: drivers/platform/x86/fujitsu-tablet.c +FUNGIBLE ETHERNET DRIVERS +M: Dimitris Michailidis <[email protected]> +L: [email protected] +S: Supported +F: drivers/net/ethernet/fungible/ + FUSE: FILESYSTEM IN USERSPACE M: Miklos Szeredi <[email protected]> L: [email protected]
drivers/net/ethernet/Kconfig +1 -0
@@ -78,6 +78,7 @@ source "drivers/net/ethernet/ezchip/Kconfig" source "drivers/net/ethernet/faraday/Kconfig" source "drivers/net/ethernet/freescale/Kconfig" source "drivers/net/ethernet/fujitsu/Kconfig" +source "drivers/net/ethernet/fungible/Kconfig" source "drivers/net/ethernet/google/Kconfig" source "drivers/net/ethernet/hisilicon/Kconfig" source "drivers/net/ethernet/huawei/Kconfig"
drivers/net/ethernet/Makefile +1 -0
@@ -41,6 +41,7 @@ obj-$(CONFIG_NET_VENDOR_EZCHIP) += ezchip/ obj-$(CONFIG_NET_VENDOR_FARADAY) += faraday/ obj-$(CONFIG_NET_VENDOR_FREESCALE) += freescale/ obj-$(CONFIG_NET_VENDOR_FUJITSU) += fujitsu/ +obj-$(CONFIG_NET_VENDOR_FUNGIBLE) += fungible/ obj-$(CONFIG_NET_VENDOR_GOOGLE) += google/ obj-$(CONFIG_NET_VENDOR_HISILICON) += hisilicon/ obj-$(CONFIG_NET_VENDOR_HUAWEI) += huawei/
drivers/net/ethernet/fungible/Kconfig new file +27 -0
@@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Fungible network driver configuration +# + +config NET_VENDOR_FUNGIBLE + bool "Fungible devices" + default y + help + If you have a Fungible network device, say Y. + + Note that the answer to this question doesn't directly affect the + kernel: saying N will just cause the configurator to skip all + the questions about Fungible cards. If you say Y, you will be asked + for your specific card in the following questions. + +if NET_VENDOR_FUNGIBLE + +config FUN_CORE + tristate + help + A service module offering basic common services to Fungible + device drivers. + +source "drivers/net/ethernet/fungible/funeth/Kconfig" + +endif # NET_VENDOR_FUNGIBLE
drivers/net/ethernet/fungible/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +# +# Makefile for the Fungible network device drivers. +# + +obj-$(CONFIG_FUN_CORE) += funcore/ +obj-$(CONFIG_FUN_ETH) += funeth/
drivers/net/ethernet/fungible/funeth/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Fungible Ethernet driver configuration +# + +config FUN_ETH + tristate "Fungible Ethernet device driver" + depends on PCI && PCI_MSI + depends on TLS && TLS_DEVICE || TLS_DEVICE=n + select NET_DEVLINK + select FUN_CORE + help + This driver supports the Ethernet functionality of Fungible adapters. + It works with both physical and virtual functions. + + To compile this driver as a module, choose M here. The module + will be called funeth.
drivers/net/ethernet/fungible/funeth/Makefile new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) + +subdir-ccflags-y += -I$(src)/../funcore -I$(src) + +obj-$(CONFIG_FUN_ETH) += funeth.o + +funeth-y := funeth_main.o funeth_rx.o funeth_tx.o funeth_devlink.o \ + funeth_ethtool.o + +funeth-$(CONFIG_TLS_DEVICE) += funeth_ktls.o
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH net-next v2 8/8] net/fungible: Kconfig, Makefiles, and MAINTAINERS
I love your patch! Yet something to improve:
Hi Dimitris,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Dimitris-Michailidis/new-Fungible-Ethernet-driver/20211231-171023 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git af30f8eaa8fe4ff1987280f716309711997bd979 config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20220101/202201011327.5iOv8qdo-lkp(a)intel.com/config) compiler: powerpc-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/7d2cbd4dcbe057ceb5df47180bed4594e7efb510
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dimitris-Michailidis/new-Fungible-Ethernet-driver/20211231-171023 git checkout 7d2cbd4dcbe057ceb5df47180bed4594e7efb510
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=powerpc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/net/ethernet/fungible/funcore/fun_dev.c: In function 'fun_enable_admin_queue':
>> drivers/net/ethernet/fungible/funcore/fun_dev.c:276:9: error: implicit declaration of function 'writeq'; did you mean 'writel'? [-Werror=implicit-function-declaration]
276 | writeq(funq->sq_dma_addr, fdev->bar + NVME_REG_ASQ);
| ^~~~~~
| writel
drivers/net/ethernet/fungible/funcore/fun_dev.c: In function 'sanitize_dev':
>> drivers/net/ethernet/fungible/funcore/fun_dev.c:717:25: error: implicit declaration of function 'readq'; did you mean 'readl'? [-Werror=implicit-function-declaration]
717 | fdev->cap_reg = readq(fdev->bar + NVME_REG_CAP);
| ^~~~~
| readlcc1: some warnings being treated as errors
vim +276 drivers/net/ethernet/fungible/funcore/fun_dev.c
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 224
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 225 /* Allocate and enable an admin queue and assign it the first IRQ vector. */
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 226 static int fun_enable_admin_queue(struct fun_dev *fdev,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 227 const struct fun_dev_params *areq)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 228 {
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 229 struct fun_queue_alloc_req qreq = {
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 230 .cqe_size_log2 = areq->cqe_size_log2,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 231 .sqe_size_log2 = areq->sqe_size_log2,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 232
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 233 .cq_depth = areq->cq_depth,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 234 .sq_depth = areq->sq_depth,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 235 .rq_depth = areq->rq_depth,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 236 };
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 237 unsigned int ntags = areq->sq_depth - 1;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 238 struct fun_queue *funq;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 239 int rc;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 240
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 241 if (fdev->admin_q)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 242 return -EEXIST;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 243
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 244 if (areq->sq_depth < AQA_MIN_QUEUE_SIZE ||
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 245 areq->sq_depth > AQA_MAX_QUEUE_SIZE ||
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 246 areq->cq_depth < AQA_MIN_QUEUE_SIZE ||
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 247 areq->cq_depth > AQA_MAX_QUEUE_SIZE)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 248 return -EINVAL;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 249
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 250 fdev->admin_q = fun_alloc_queue(fdev, 0, &qreq);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 251 if (!fdev->admin_q)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 252 return -ENOMEM;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 253
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 254 rc = fun_init_cmd_ctx(fdev, ntags);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 255 if (rc)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 256 goto free_q;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 257
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 258 rc = sbitmap_queue_init_node(&fdev->admin_sbq, ntags, -1, false,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 259 GFP_KERNEL, dev_to_node(fdev->dev));
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 260 if (rc)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 261 goto free_cmd_ctx;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 262
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 263 funq = fdev->admin_q;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 264 funq->cq_vector = 0;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 265 rc = fun_request_irq(funq, dev_name(fdev->dev), fun_admin_irq, funq);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 266 if (rc)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 267 goto free_sbq;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 268
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 269 fun_set_cq_callback(funq, fun_complete_admin_cmd, NULL);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 270 fdev->adminq_cb = areq->event_cb;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 271
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 272 writel((funq->sq_depth - 1) << AQA_ASQS_SHIFT |
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 273 (funq->cq_depth - 1) << AQA_ACQS_SHIFT,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 274 fdev->bar + NVME_REG_AQA);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 275
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 @276 writeq(funq->sq_dma_addr, fdev->bar + NVME_REG_ASQ);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 277 writeq(funq->cq_dma_addr, fdev->bar + NVME_REG_ACQ);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 278
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 279 rc = fun_enable_ctrl(fdev, areq->cqe_size_log2, areq->sqe_size_log2);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 280 if (rc)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 281 goto free_irq;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 282
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 283 if (areq->rq_depth) {
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 284 rc = fun_create_rq(funq);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 285 if (rc)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 286 goto disable_ctrl;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 287
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 288 funq_rq_post(funq);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 289 }
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 290
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 291 return 0;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 292
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 293 disable_ctrl:
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 294 fun_disable_ctrl(fdev);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 295 free_irq:
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 296 fun_free_irq(funq);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 297 free_sbq:
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 298 sbitmap_queue_free(&fdev->admin_sbq);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 299 free_cmd_ctx:
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 300 kvfree(fdev->cmd_ctx);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 301 fdev->cmd_ctx = NULL;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 302 free_q:
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 303 fun_free_queue(fdev->admin_q);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 304 fdev->admin_q = NULL;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 305 return rc;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 306 }
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 307 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [PATCH net-next v2 8/8] net/fungible: Kconfig, Makefiles, and MAINTAINERS
In reply to Dimitris MichailidisI love your patch! Yet something to improve:
Hi Dimitris,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Dimitris-Michailidis/new-Fungible-Ethernet-driver/20211231-171023 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git af30f8eaa8fe4ff1987280f716309711997bd979 config: xtensa-allyesconfig (https://download.01.org/0day-ci/archive/20220102/202201021013.ZSZDNf73-lkp(a)intel.com/config) compiler: xtensa-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/7d2cbd4dcbe057ceb5df47180bed4594e7efb510
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dimitris-Michailidis/new-Fungible-Ethernet-driver/20211231-171023 git checkout 7d2cbd4dcbe057ceb5df47180bed4594e7efb510
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=xtensa SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/net/ethernet/fungible/funcore/fun_dev.c: In function 'fun_enable_admin_queue':
>> drivers/net/ethernet/fungible/funcore/fun_dev.c:276:9: error: implicit declaration of function 'writeq'; did you mean 'writel'? [-Werror=implicit-function-declaration]
276 | writeq(funq->sq_dma_addr, fdev->bar + NVME_REG_ASQ);
| ^~~~~~
| writel
drivers/net/ethernet/fungible/funcore/fun_dev.c: In function 'sanitize_dev':
>> drivers/net/ethernet/fungible/funcore/fun_dev.c:717:25: error: implicit declaration of function 'readq'; did you mean 'readl'? [-Werror=implicit-function-declaration]
717 | fdev->cap_reg = readq(fdev->bar + NVME_REG_CAP);
| ^~~~~
| readl
cc1: some warnings being treated as errors
--
In file included from drivers/net/ethernet/fungible/funeth/funeth_main.c:16:
>> drivers/net/ethernet/fungible/funeth/funeth.h:10:10: fatal error: fun_dev.h: No such file or directory
10 | #include "fun_dev.h"
| ^~~~~~~~~~~compilation terminated.
vim +276 drivers/net/ethernet/fungible/funcore/fun_dev.c
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 224
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 225 /* Allocate and enable an admin queue and assign it the first IRQ vector. */
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 226 static int fun_enable_admin_queue(struct fun_dev *fdev,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 227 const struct fun_dev_params *areq)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 228 {
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 229 struct fun_queue_alloc_req qreq = {
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 230 .cqe_size_log2 = areq->cqe_size_log2,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 231 .sqe_size_log2 = areq->sqe_size_log2,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 232
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 233 .cq_depth = areq->cq_depth,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 234 .sq_depth = areq->sq_depth,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 235 .rq_depth = areq->rq_depth,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 236 };
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 237 unsigned int ntags = areq->sq_depth - 1;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 238 struct fun_queue *funq;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 239 int rc;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 240
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 241 if (fdev->admin_q)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 242 return -EEXIST;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 243
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 244 if (areq->sq_depth < AQA_MIN_QUEUE_SIZE ||
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 245 areq->sq_depth > AQA_MAX_QUEUE_SIZE ||
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 246 areq->cq_depth < AQA_MIN_QUEUE_SIZE ||
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 247 areq->cq_depth > AQA_MAX_QUEUE_SIZE)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 248 return -EINVAL;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 249
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 250 fdev->admin_q = fun_alloc_queue(fdev, 0, &qreq);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 251 if (!fdev->admin_q)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 252 return -ENOMEM;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 253
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 254 rc = fun_init_cmd_ctx(fdev, ntags);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 255 if (rc)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 256 goto free_q;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 257
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 258 rc = sbitmap_queue_init_node(&fdev->admin_sbq, ntags, -1, false,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 259 GFP_KERNEL, dev_to_node(fdev->dev));
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 260 if (rc)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 261 goto free_cmd_ctx;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 262
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 263 funq = fdev->admin_q;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 264 funq->cq_vector = 0;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 265 rc = fun_request_irq(funq, dev_name(fdev->dev), fun_admin_irq, funq);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 266 if (rc)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 267 goto free_sbq;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 268
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 269 fun_set_cq_callback(funq, fun_complete_admin_cmd, NULL);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 270 fdev->adminq_cb = areq->event_cb;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 271
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 272 writel((funq->sq_depth - 1) << AQA_ASQS_SHIFT |
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 273 (funq->cq_depth - 1) << AQA_ACQS_SHIFT,
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 274 fdev->bar + NVME_REG_AQA);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 275
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 @276 writeq(funq->sq_dma_addr, fdev->bar + NVME_REG_ASQ);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 277 writeq(funq->cq_dma_addr, fdev->bar + NVME_REG_ACQ);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 278
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 279 rc = fun_enable_ctrl(fdev, areq->cqe_size_log2, areq->sqe_size_log2);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 280 if (rc)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 281 goto free_irq;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 282
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 283 if (areq->rq_depth) {
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 284 rc = fun_create_rq(funq);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 285 if (rc)
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 286 goto disable_ctrl;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 287
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 288 funq_rq_post(funq);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 289 }
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 290
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 291 return 0;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 292
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 293 disable_ctrl:
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 294 fun_disable_ctrl(fdev);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 295 free_irq:
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 296 fun_free_irq(funq);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 297 free_sbq:
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 298 sbitmap_queue_free(&fdev->admin_sbq);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 299 free_cmd_ctx:
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 300 kvfree(fdev->cmd_ctx);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 301 fdev->cmd_ctx = NULL;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 302 free_q:
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 303 fun_free_queue(fdev->admin_q);
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 304 fdev->admin_q = NULL;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 305 return rc;
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 306 }
ed0cb459f5bcf4 Dimitris Michailidis 2021-12-31 307 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Jakub Kicinski
maintainerQuoted 11 lines · On Fri, 31 Dec 2021 01:08:25 -0800 Dimitris Michailidis wrote:
This patch series contains a new network driver for the Ethernet functionality of Fungible cards.
It contains two modules. The first one in patch 2 is a library module that implements some of the device setup, queue managenent, and support for operating an admin queue. These are placed in a separate module because the cards provide a number of PCI functions handled by different types of drivers and all use the same common means to interact with the device. Each of the drivers will be relying on this library module for them.
Quoted 1 line
The remaining patches provide the Ethernet driver for the cards.
Still fails to build for me, I use:
make C=1 W=1 O=build_allmodconfig/ drivers/net/ethernet/fungible/
Quoted 13 lines · Jakub Kicinski
Quoted 11 lines · On Fri, 31 Dec 2021 01:08:25 -0800 Dimitris Michailidis wrote:
This patch series contains a new network driver for the Ethernet functionality of Fungible cards.
It contains two modules. The first one in patch 2 is a library module that implements some of the device setup, queue managenent, and support for operating an admin queue. These are placed in a separate module because the cards provide a number of PCI functions handled by different types of drivers and all use the same common means to interact with the device. Each of the drivers will be relying on this library module for them.
Quoted 5 lines
Quoted 1 line
The remaining patches provide the Ethernet driver for the cards.
Still fails to build for me, I use:
make C=1 W=1 O=build_allmodconfig/
drivers/net/ethernet/fungible/
I've figured it out and will be fixed in v3. There's one issue with O= and one with builds on 32b architectures.