Commit 355440a6 authored by Alexander Duyck's avatar Alexander Duyck Committed by Jakub Kicinski
Browse files

eth: fbnic: Write the TCAM tables used for RSS control and Rx to host



RSS is controlled by the Rx filter tables. Program rules matching
on appropriate traffic types and set hashing fields using actions.
We need a separate set of rules for broadcast and multicast
because the action there needs to include forwarding to BMC.

This patch only initializes the default settings, the control
of the configuration using ethtool will come soon.

With this the necessary rules are put in place to enable Rx of packets by
the host.

Signed-off-by: default avatarAlexander Duyck <alexanderduyck@fb.com>
Link: https://patch.msgid.link/172079943591.1778861.17778587068185893750.stgit@ahduyck-xeon-server.home.arpa


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent eb690ef8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ struct fbnic_dev {
	u32 readrq;

	/* Local copy of the devices TCAM */
	struct fbnic_act_tcam act_tcam[FBNIC_RPC_TCAM_ACT_NUM_ENTRIES];
	struct fbnic_mac_addr mac_addr[FBNIC_RPC_TCAM_MACDA_NUM_ENTRIES];
	u8 mac_addr_boundary;

+59 −0
Original line number Diff line number Diff line
@@ -537,20 +537,79 @@ enum {
#define FBNIC_RPC_RMI_CONFIG_FCS_PRESENT	CSR_BIT(8)
#define FBNIC_RPC_RMI_CONFIG_ENABLE		CSR_BIT(12)
#define FBNIC_RPC_RMI_CONFIG_MTU		CSR_GENMASK(31, 16)

#define FBNIC_RPC_ACT_TBL0_DEFAULT	0x0840a		/* 0x21028 */
#define FBNIC_RPC_ACT_TBL0_DROP			CSR_BIT(0)
#define FBNIC_RPC_ACT_TBL0_DEST_MASK		CSR_GENMASK(3, 1)
enum {
	FBNIC_RPC_ACT_TBL0_DEST_HOST	= 1,
	FBNIC_RPC_ACT_TBL0_DEST_BMC	= 2,
	FBNIC_RPC_ACT_TBL0_DEST_EI	= 4,
};

#define FBNIC_RPC_ACT_TBL0_DMA_HINT		CSR_GENMASK(24, 16)
#define FBNIC_RPC_ACT_TBL0_RSS_CTXT_ID		CSR_BIT(30)

#define FBNIC_RPC_ACT_TBL1_DEFAULT	0x0840b		/* 0x2102c */
#define FBNIC_RPC_ACT_TBL1_RSS_ENA_MASK		CSR_GENMASK(15, 0)
enum {
	FBNIC_RPC_ACT_TBL1_RSS_ENA_IP_SRC	= 1,
	FBNIC_RPC_ACT_TBL1_RSS_ENA_IP_DST	= 2,
	FBNIC_RPC_ACT_TBL1_RSS_ENA_L4_SRC	= 4,
	FBNIC_RPC_ACT_TBL1_RSS_ENA_L4_DST	= 8,
	FBNIC_RPC_ACT_TBL1_RSS_ENA_L2_DA	= 16,
	FBNIC_RPC_ACT_TBL1_RSS_ENA_L4_RSS_BYTE	= 32,
	FBNIC_RPC_ACT_TBL1_RSS_ENA_IV6_FL_LBL	= 64,
	FBNIC_RPC_ACT_TBL1_RSS_ENA_OV6_FL_LBL	= 128,
	FBNIC_RPC_ACT_TBL1_RSS_ENA_DSCP		= 256,
	FBNIC_RPC_ACT_TBL1_RSS_ENA_L3_PROT	= 512,
	FBNIC_RPC_ACT_TBL1_RSS_ENA_L4_PROT	= 1024,
};

#define FBNIC_RPC_RSS_KEY(n)		(0x0840c + (n))	/* 0x21030 + 4*n */
#define FBNIC_RPC_RSS_KEY_BIT_LEN		425
#define FBNIC_RPC_RSS_KEY_BYTE_LEN \
	DIV_ROUND_UP(FBNIC_RPC_RSS_KEY_BIT_LEN, 8)
#define FBNIC_RPC_RSS_KEY_DWORD_LEN \
	DIV_ROUND_UP(FBNIC_RPC_RSS_KEY_BIT_LEN, 32)
#define FBNIC_RPC_RSS_KEY_LAST_IDX \
	(FBNIC_RPC_RSS_KEY_DWORD_LEN - 1)
#define FBNIC_RPC_RSS_KEY_LAST_MASK \
	CSR_GENMASK(31, \
		    FBNIC_RPC_RSS_KEY_DWORD_LEN * 32 - \
		    FBNIC_RPC_RSS_KEY_BIT_LEN)

#define FBNIC_RPC_TCAM_MACDA_VALIDATE	0x0852d		/* 0x214b4 */
#define FBNIC_CSR_END_RPC		0x0856b	/* CSR section delimiter */

/* RPC RAM Registers */

#define FBNIC_CSR_START_RPC_RAM		0x08800	/* CSR section delimiter */
#define FBNIC_RPC_ACT_TBL0(n)		(0x08800 + (n))	/* 0x22000 + 4*n */
#define FBNIC_RPC_ACT_TBL1(n)		(0x08840 + (n))	/* 0x22100 + 4*n */
#define FBNIC_RPC_ACT_TBL_NUM_ENTRIES		64

/* TCAM Tables */
#define FBNIC_RPC_TCAM_VALIDATE			CSR_BIT(31)

/* 64 Action TCAM Entries, 12 registers
 * 3 mixed, src port, dst port, 6 L4 words, and Validate
 */
#define FBNIC_RPC_TCAM_ACT(m, n) \
	(0x08880 + 0x40 * (n) + (m))		/* 0x22200 + 256*n + 4*m */

#define FBNIC_RPC_TCAM_ACT_VALUE		CSR_GENMASK(15, 0)
#define FBNIC_RPC_TCAM_ACT_MASK			CSR_GENMASK(31, 16)

#define FBNIC_RPC_TCAM_MACDA(m, n) \
	(0x08b80 + 0x20 * (n) + (m))		/* 0x022e00 + 128*n + 4*m */
#define FBNIC_RPC_TCAM_MACDA_VALUE		CSR_GENMASK(15, 0)
#define FBNIC_RPC_TCAM_MACDA_MASK		CSR_GENMASK(31, 16)

#define FBNIC_RPC_RSS_TBL(n, m) \
	(0x08d20 + 0x100 * (n) + (m))		/* 0x023480 + 1024*n + 4*m */
#define FBNIC_RPC_RSS_TBL_COUNT			2
#define FBNIC_RPC_RSS_TBL_SIZE			256
#define FBNIC_CSR_END_RPC_RAM		0x08f1f	/* CSR section delimiter */

/* Fab Registers */
+6 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ int __fbnic_open(struct fbnic_net *fbn)
		goto release_ownership;
	/* Pull the BMC config and initialize the RPC */
	fbnic_bmc_rpc_init(fbd);
	fbnic_rss_reinit(fbd, fbn);

	return 0;
release_ownership:
@@ -262,6 +263,7 @@ void __fbnic_set_rx_mode(struct net_device *netdev)
	fbnic_sift_macda(fbd);

	/* Write updates to hardware */
	fbnic_write_rules(fbd);
	fbnic_write_macda(fbd);
}

@@ -400,6 +402,10 @@ struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd)

	fbnic_reset_queues(fbn, default_queues, default_queues);

	fbnic_reset_indir_tbl(fbn);
	fbnic_rss_key_fill(fbn->rss_key);
	fbnic_rss_init_en_mask(fbn);

	netdev->features |=
		NETIF_F_RXHASH |
		NETIF_F_SG |
+7 −0
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@
#include <linux/types.h>
#include <linux/phylink.h>

#include "fbnic_csr.h"
#include "fbnic_rpc.h"
#include "fbnic_txrx.h"

struct fbnic_net {
@@ -34,7 +36,12 @@ struct fbnic_net {
	u16 num_tx_queues;
	u16 num_rx_queues;

	u8 indir_tbl[FBNIC_RPC_RSS_TBL_COUNT][FBNIC_RPC_RSS_TBL_SIZE];
	u32 rss_key[FBNIC_RPC_RSS_KEY_DWORD_LEN];
	u32 rss_flow_hash[FBNIC_NUM_HASH_OPT];

	u64 link_down_events;

	struct list_head napis;
};

+4 −0
Original line number Diff line number Diff line
@@ -133,6 +133,8 @@ void fbnic_up(struct fbnic_net *fbn)

	fbnic_fill(fbn);

	fbnic_rss_reinit_hw(fbn->fbd, fbn);

	__fbnic_set_rx_mode(fbn->netdev);

	/* Enable Tx/Rx processing */
@@ -151,6 +153,8 @@ static void fbnic_down_noidle(struct fbnic_net *fbn)
	netif_tx_disable(fbn->netdev);

	fbnic_clear_rx_mode(fbn->netdev);
	fbnic_clear_rules(fbn->fbd);
	fbnic_rss_disable_hw(fbn->fbd);
	fbnic_disable(fbn);
}

Loading