Commit a29b8eb6 authored by Alexander Duyck's avatar Alexander Duyck Committed by Jakub Kicinski

eth: fbnic: Add basic Rx handling

Handle Rx packets with basic csum and Rx hash offloads.

NIC writes back to the completion ring a head buffer descriptor
(data buffer allocated from header pages), variable number of payload
descriptors (data buffers in payload pages), an optional metadata
descriptor (type 2) and finally the primary metadata descriptor
(type 3).

This format makes scatter support fairly easy - start gathering
the pages when we see head page, gather until we see the primary
metadata descriptor, do the processing. Use XDP infra to collect
the packet fragments as we traverse the descriptors. XDP itself
is not supported yet, but it will be soon.
Signed-off-by: default avatarAlexander Duyck <alexanderduyck@fb.com>
Link: https://patch.msgid.link/172079942839.1778861.10509071985738726125.stgit@ahduyck-xeon-server.home.arpaSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 9a57bacd
......@@ -121,6 +121,69 @@ enum {
#define FBNIC_BD_PAGE_ID_MASK \
(FBNIC_BD_DESC_ID_MASK & ~FBNIC_BD_FRAG_ID_MASK)
/* Rx Completion Queue Descriptors */
#define FBNIC_RCD_TYPE_MASK DESC_GENMASK(62, 61)
enum {
FBNIC_RCD_TYPE_HDR_AL = 0,
FBNIC_RCD_TYPE_PAY_AL = 1,
FBNIC_RCD_TYPE_OPT_META = 2,
FBNIC_RCD_TYPE_META = 3,
};
#define FBNIC_RCD_DONE DESC_BIT(63)
/* Address/Length Completion Descriptors */
#define FBNIC_RCD_AL_BUFF_ID_MASK DESC_GENMASK(15, 0)
#define FBNIC_RCD_AL_BUFF_FRAG_MASK (FBNIC_BD_FRAG_COUNT - 1)
#define FBNIC_RCD_AL_BUFF_PAGE_MASK \
(FBNIC_RCD_AL_BUFF_ID_MASK & ~FBNIC_RCD_AL_BUFF_FRAG_MASK)
#define FBNIC_RCD_AL_BUFF_LEN_MASK DESC_GENMASK(28, 16)
#define FBNIC_RCD_AL_BUFF_OFF_MASK DESC_GENMASK(43, 32)
#define FBNIC_RCD_AL_PAGE_FIN DESC_BIT(60)
/* Header AL specific values */
#define FBNIC_RCD_HDR_AL_OVERFLOW DESC_BIT(53)
#define FBNIC_RCD_HDR_AL_DMA_HINT_MASK DESC_GENMASK(59, 54)
enum {
FBNIC_RCD_HDR_AL_DMA_HINT_NONE = 0,
FBNIC_RCD_HDR_AL_DMA_HINT_L2 = 1,
FBNIC_RCD_HDR_AL_DMA_HINT_L3 = 2,
FBNIC_RCD_HDR_AL_DMA_HINT_L4 = 4,
};
/* Optional Metadata Completion Descriptors */
#define FBNIC_RCD_OPT_META_TS_MASK DESC_GENMASK(39, 0)
#define FBNIC_RCD_OPT_META_ACTION_MASK DESC_GENMASK(45, 40)
#define FBNIC_RCD_OPT_META_ACTION DESC_BIT(57)
#define FBNIC_RCD_OPT_META_TS DESC_BIT(58)
#define FBNIC_RCD_OPT_META_TYPE_MASK DESC_GENMASK(60, 59)
/* Metadata Completion Descriptors */
#define FBNIC_RCD_META_RSS_HASH_MASK DESC_GENMASK(31, 0)
#define FBNIC_RCD_META_L2_CSUM_MASK DESC_GENMASK(47, 32)
#define FBNIC_RCD_META_L3_TYPE_MASK DESC_GENMASK(49, 48)
enum {
FBNIC_RCD_META_L3_TYPE_OTHER = 0,
FBNIC_RCD_META_L3_TYPE_IPV4 = 1,
FBNIC_RCD_META_L3_TYPE_IPV6 = 2,
FBNIC_RCD_META_L3_TYPE_V6V6 = 3,
};
#define FBNIC_RCD_META_L4_TYPE_MASK DESC_GENMASK(51, 50)
enum {
FBNIC_RCD_META_L4_TYPE_OTHER = 0,
FBNIC_RCD_META_L4_TYPE_TCP = 1,
FBNIC_RCD_META_L4_TYPE_UDP = 2,
};
#define FBNIC_RCD_META_L4_CSUM_UNNECESSARY DESC_BIT(52)
#define FBNIC_RCD_META_ERR_MAC_EOP DESC_BIT(53)
#define FBNIC_RCD_META_ERR_TRUNCATED_FRAME DESC_BIT(54)
#define FBNIC_RCD_META_ERR_PARSER DESC_BIT(55)
#define FBNIC_RCD_META_UNCORRECTABLE_ERR_MASK \
(FBNIC_RCD_META_ERR_MAC_EOP | FBNIC_RCD_META_ERR_TRUNCATED_FRAME)
#define FBNIC_RCD_META_ECN DESC_BIT(60)
/* Register Definitions
*
* The registers are laid as indexes into an le32 array. As such the actual
......
......@@ -171,8 +171,10 @@ struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd)
fbnic_reset_queues(fbn, default_queues, default_queues);
netdev->features |=
NETIF_F_RXHASH |
NETIF_F_SG |
NETIF_F_HW_CSUM;
NETIF_F_HW_CSUM |
NETIF_F_RXCSUM;
netdev->hw_features |= netdev->features;
netdev->vlan_features |= netdev->features;
......
......@@ -195,6 +195,9 @@ static void fbnic_service_task(struct work_struct *work)
fbnic_health_check(fbd);
if (netif_carrier_ok(fbd->netdev))
fbnic_napi_depletion_check(fbd->netdev);
if (netif_running(fbd->netdev))
schedule_delayed_work(&fbd->service_task, HZ);
......
......@@ -5,6 +5,7 @@
#define _FBNIC_TXRX_H_
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/types.h>
#include <net/xdp.h>
......@@ -120,6 +121,7 @@ void fbnic_disable(struct fbnic_net *fbn);
void fbnic_flush(struct fbnic_net *fbn);
void fbnic_fill(struct fbnic_net *fbn);
void fbnic_napi_depletion_check(struct net_device *netdev);
int fbnic_wait_all_queues_idle(struct fbnic_dev *fbd, bool may_fail);
#endif /* _FBNIC_TXRX_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment