Commit 9a57bacd authored by Alexander Duyck's avatar Alexander Duyck Committed by Jakub Kicinski

eth: fbnic: Add basic Tx handling

Handle Tx of simple packets. Support checksum offload and gather.
Use .ndo_features_check to make sure packet geometry will be
supported by the HW, i.e. we can fit the header lengths into
the descriptor fields.

The device writes to the completion rings the position of the tail
(consumer) pointer. Read all those writebacks, obviously the last
one will be the most recent, complete skbs up to that point.
Signed-off-by: default avatarAlexander Duyck <alexanderduyck@fb.com>
Link: https://patch.msgid.link/172079942464.1778861.17919428039428796180.stgit@ahduyck-xeon-server.home.arpaSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 69684376
......@@ -24,6 +24,72 @@
#define FBNIC_CLOCK_FREQ (600 * (1000 * 1000))
/* Transmit Work Descriptor Format */
/* Length, Type, Offset Masks and Shifts */
#define FBNIC_TWD_L2_HLEN_MASK DESC_GENMASK(5, 0)
#define FBNIC_TWD_L3_TYPE_MASK DESC_GENMASK(7, 6)
enum {
FBNIC_TWD_L3_TYPE_OTHER = 0,
FBNIC_TWD_L3_TYPE_IPV4 = 1,
FBNIC_TWD_L3_TYPE_IPV6 = 2,
FBNIC_TWD_L3_TYPE_V6V6 = 3,
};
#define FBNIC_TWD_L3_OHLEN_MASK DESC_GENMASK(15, 8)
#define FBNIC_TWD_L3_IHLEN_MASK DESC_GENMASK(23, 16)
enum {
FBNIC_TWD_L4_TYPE_OTHER = 0,
FBNIC_TWD_L4_TYPE_TCP = 1,
FBNIC_TWD_L4_TYPE_UDP = 2,
};
#define FBNIC_TWD_CSUM_OFFSET_MASK DESC_GENMASK(27, 24)
#define FBNIC_TWD_L4_HLEN_MASK DESC_GENMASK(31, 28)
/* Flags and Type */
#define FBNIC_TWD_L4_TYPE_MASK DESC_GENMASK(33, 32)
#define FBNIC_TWD_FLAG_REQ_TS DESC_BIT(34)
#define FBNIC_TWD_FLAG_REQ_LSO DESC_BIT(35)
#define FBNIC_TWD_FLAG_REQ_CSO DESC_BIT(36)
#define FBNIC_TWD_FLAG_REQ_COMPLETION DESC_BIT(37)
#define FBNIC_TWD_FLAG_DEST_MAC DESC_BIT(43)
#define FBNIC_TWD_FLAG_DEST_BMC DESC_BIT(44)
#define FBNIC_TWD_FLAG_DEST_FW DESC_BIT(45)
#define FBNIC_TWD_TYPE_MASK DESC_GENMASK(47, 46)
enum {
FBNIC_TWD_TYPE_META = 0,
FBNIC_TWD_TYPE_OPT_META = 1,
FBNIC_TWD_TYPE_AL = 2,
FBNIC_TWD_TYPE_LAST_AL = 3,
};
/* MSS and Completion Req */
#define FBNIC_TWD_MSS_MASK DESC_GENMASK(61, 48)
#define FBNIC_TWD_TS_MASK DESC_GENMASK(39, 0)
#define FBNIC_TWD_ADDR_MASK DESC_GENMASK(45, 0)
#define FBNIC_TWD_LEN_MASK DESC_GENMASK(63, 48)
/* Tx Completion Descriptor Format */
#define FBNIC_TCD_TYPE0_HEAD0_MASK DESC_GENMASK(15, 0)
#define FBNIC_TCD_TYPE0_HEAD1_MASK DESC_GENMASK(31, 16)
#define FBNIC_TCD_TYPE1_TS_MASK DESC_GENMASK(39, 0)
#define FBNIC_TCD_STATUS_MASK DESC_GENMASK(59, 48)
#define FBNIC_TCD_STATUS_TS_INVALID DESC_BIT(48)
#define FBNIC_TCD_STATUS_ILLEGAL_TS_REQ DESC_BIT(49)
#define FBNIC_TCD_TWQ1 DESC_BIT(60)
#define FBNIC_TCD_TYPE_MASK DESC_GENMASK(62, 61)
enum {
FBNIC_TCD_TYPE_0 = 0,
FBNIC_TCD_TYPE_1 = 1,
};
#define FBNIC_TCD_DONE DESC_BIT(63)
/* Rx Buffer Descriptor Format
*
* The layout of this can vary depending on the page size of the system.
......
......@@ -91,6 +91,7 @@ static const struct net_device_ops fbnic_netdev_ops = {
.ndo_stop = fbnic_stop,
.ndo_validate_addr = eth_validate_addr,
.ndo_start_xmit = fbnic_xmit_frame,
.ndo_features_check = fbnic_features_check,
};
void fbnic_reset_queues(struct fbnic_net *fbn,
......@@ -169,6 +170,14 @@ struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd)
fbnic_reset_queues(fbn, default_queues, default_queues);
netdev->features |=
NETIF_F_SG |
NETIF_F_HW_CSUM;
netdev->hw_features |= netdev->features;
netdev->vlan_features |= netdev->features;
netdev->hw_enc_features |= netdev->features;
netdev->min_mtu = IPV6_MIN_MTU;
netdev->max_mtu = FBNIC_MAX_JUMBO_FRAME_SIZE - ETH_HLEN;
......
......@@ -10,6 +10,18 @@
struct fbnic_net;
/* Guarantee we have space needed for storing the buffer
* To store the buffer we need:
* 1 descriptor per page
* + 1 descriptor for skb head
* + 2 descriptors for metadata and optional metadata
* + 7 descriptors to keep tail out of the same cacheline as head
* If we cannot guarantee that then we should return TX_BUSY
*/
#define FBNIC_MAX_SKB_DESC (MAX_SKB_FRAGS + 10)
#define FBNIC_TX_DESC_WAKEUP (FBNIC_MAX_SKB_DESC * 2)
#define FBNIC_TX_DESC_MIN roundup_pow_of_two(FBNIC_TX_DESC_WAKEUP)
#define FBNIC_MAX_TXQS 128u
#define FBNIC_MAX_RXQS 128u
......@@ -93,6 +105,9 @@ struct fbnic_napi_vector {
#define FBNIC_MAX_RXQS 128u
netdev_tx_t fbnic_xmit_frame(struct sk_buff *skb, struct net_device *dev);
netdev_features_t
fbnic_features_check(struct sk_buff *skb, struct net_device *dev,
netdev_features_t features);
int fbnic_alloc_napi_vectors(struct fbnic_net *fbn);
void fbnic_free_napi_vectors(struct fbnic_net *fbn);
......
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