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

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.arpaSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent eb690ef8
......@@ -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;
......
......@@ -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 */
......
......@@ -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,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;
};
......
......@@ -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);
}
......
This diff is collapsed.
......@@ -54,9 +54,21 @@ struct fbnic_act_tcam {
};
enum {
FBNIC_RSS_EN_HOST_UDP6,
FBNIC_RSS_EN_HOST_UDP4,
FBNIC_RSS_EN_HOST_TCP6,
FBNIC_RSS_EN_HOST_TCP4,
FBNIC_RSS_EN_HOST_IP6,
FBNIC_RSS_EN_HOST_IP4,
FBNIC_RSS_EN_HOST_ETHER,
FBNIC_RSS_EN_XCAST_UDP6,
#define FBNIC_RSS_EN_NUM_UNICAST FBNIC_RSS_EN_XCAST_UDP6
FBNIC_RSS_EN_XCAST_UDP4,
FBNIC_RSS_EN_XCAST_TCP6,
FBNIC_RSS_EN_XCAST_TCP4,
FBNIC_RSS_EN_XCAST_IP6,
FBNIC_RSS_EN_XCAST_IP4,
FBNIC_RSS_EN_XCAST_ETHER,
#define FBNIC_RSS_EN_NUM_UNICAST FBNIC_RSS_EN_XCAST_ETHER
FBNIC_RSS_EN_NUM_ENTRIES
};
......@@ -91,8 +103,22 @@ enum {
#define FBNIC_MAC_ADDR_T_HOST_LEN \
(FBNIC_MAC_ADDR_T_HOST_LAST - FBNIC_MAC_ADDR_T_HOST_START)
#define FBNIC_RPC_TCAM_ACT0_IPSRC_IDX CSR_GENMASK(2, 0)
#define FBNIC_RPC_TCAM_ACT0_IPSRC_VALID CSR_BIT(3)
#define FBNIC_RPC_TCAM_ACT0_IPDST_IDX CSR_GENMASK(6, 4)
#define FBNIC_RPC_TCAM_ACT0_IPDST_VALID CSR_BIT(7)
#define FBNIC_RPC_TCAM_ACT0_OUTER_IPSRC_IDX CSR_GENMASK(10, 8)
#define FBNIC_RPC_TCAM_ACT0_OUTER_IPSRC_VALID CSR_BIT(11)
#define FBNIC_RPC_TCAM_ACT0_OUTER_IPDST_IDX CSR_GENMASK(14, 12)
#define FBNIC_RPC_TCAM_ACT0_OUTER_IPDST_VALID CSR_BIT(15)
#define FBNIC_RPC_TCAM_ACT1_L2_MACDA_IDX CSR_GENMASK(9, 5)
#define FBNIC_RPC_TCAM_ACT1_L2_MACDA_VALID CSR_BIT(10)
#define FBNIC_RPC_TCAM_ACT1_IP_IS_V6 CSR_BIT(11)
#define FBNIC_RPC_TCAM_ACT1_IP_VALID CSR_BIT(12)
#define FBNIC_RPC_TCAM_ACT1_OUTER_IP_VALID CSR_BIT(13)
#define FBNIC_RPC_TCAM_ACT1_L4_IS_UDP CSR_BIT(14)
#define FBNIC_RPC_TCAM_ACT1_L4_VALID CSR_BIT(15)
/* TCAM 0 - 3 reserved for BMC MAC addresses */
#define FBNIC_RPC_TCAM_MACDA_BMC_ADDR_IDX 0
......@@ -114,11 +140,32 @@ enum {
/* Reserved for use to record Multicast promisc, or Promiscuous */
#define FBNIC_RPC_TCAM_MACDA_PROMISC_IDX 31
enum {
FBNIC_UDP6_HASH_OPT,
FBNIC_UDP4_HASH_OPT,
FBNIC_TCP6_HASH_OPT,
FBNIC_TCP4_HASH_OPT,
#define FBNIC_L4_HASH_OPT FBNIC_TCP4_HASH_OPT
FBNIC_IPV6_HASH_OPT,
FBNIC_IPV4_HASH_OPT,
#define FBNIC_IP_HASH_OPT FBNIC_IPV4_HASH_OPT
FBNIC_ETHER_HASH_OPT,
FBNIC_NUM_HASH_OPT,
};
struct fbnic_dev;
struct fbnic_net;
void fbnic_bmc_rpc_init(struct fbnic_dev *fbd);
void fbnic_bmc_rpc_all_multi_config(struct fbnic_dev *fbd, bool enable_host);
void fbnic_reset_indir_tbl(struct fbnic_net *fbn);
void fbnic_rss_key_fill(u32 *buffer);
void fbnic_rss_init_en_mask(struct fbnic_net *fbn);
void fbnic_rss_disable_hw(struct fbnic_dev *fbd);
void fbnic_rss_reinit_hw(struct fbnic_dev *fbd, struct fbnic_net *fbn);
void fbnic_rss_reinit(struct fbnic_dev *fbd, struct fbnic_net *fbn);
int __fbnic_xc_unsync(struct fbnic_mac_addr *mac_addr, unsigned int tcam_idx);
struct fbnic_mac_addr *__fbnic_uc_sync(struct fbnic_dev *fbd,
const unsigned char *addr);
......@@ -136,4 +183,7 @@ static inline int __fbnic_mc_unsync(struct fbnic_mac_addr *mac_addr)
{
return __fbnic_xc_unsync(mac_addr, FBNIC_MAC_ADDR_T_MULTICAST);
}
void fbnic_clear_rules(struct fbnic_dev *fbd);
void fbnic_write_rules(struct fbnic_dev *fbd);
#endif /* _FBNIC_RPC_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