Skip to content

Commit 355440a

Browse files
ahduyckkuba-moo
authored andcommitted
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: Alexander Duyck <[email protected]> Link: https://patch.msgid.link/172079943591.1778861.17778587068185893750.stgit@ahduyck-xeon-server.home.arpa Signed-off-by: Jakub Kicinski <[email protected]>
1 parent eb690ef commit 355440a

File tree

7 files changed

+498
-1
lines changed

7 files changed

+498
-1
lines changed

drivers/net/ethernet/meta/fbnic/fbnic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct fbnic_dev {
4141
u32 readrq;
4242

4343
/* Local copy of the devices TCAM */
44+
struct fbnic_act_tcam act_tcam[FBNIC_RPC_TCAM_ACT_NUM_ENTRIES];
4445
struct fbnic_mac_addr mac_addr[FBNIC_RPC_TCAM_MACDA_NUM_ENTRIES];
4546
u8 mac_addr_boundary;
4647

drivers/net/ethernet/meta/fbnic/fbnic_csr.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,20 +537,79 @@ enum {
537537
#define FBNIC_RPC_RMI_CONFIG_FCS_PRESENT CSR_BIT(8)
538538
#define FBNIC_RPC_RMI_CONFIG_ENABLE CSR_BIT(12)
539539
#define FBNIC_RPC_RMI_CONFIG_MTU CSR_GENMASK(31, 16)
540+
541+
#define FBNIC_RPC_ACT_TBL0_DEFAULT 0x0840a /* 0x21028 */
542+
#define FBNIC_RPC_ACT_TBL0_DROP CSR_BIT(0)
543+
#define FBNIC_RPC_ACT_TBL0_DEST_MASK CSR_GENMASK(3, 1)
544+
enum {
545+
FBNIC_RPC_ACT_TBL0_DEST_HOST = 1,
546+
FBNIC_RPC_ACT_TBL0_DEST_BMC = 2,
547+
FBNIC_RPC_ACT_TBL0_DEST_EI = 4,
548+
};
549+
550+
#define FBNIC_RPC_ACT_TBL0_DMA_HINT CSR_GENMASK(24, 16)
551+
#define FBNIC_RPC_ACT_TBL0_RSS_CTXT_ID CSR_BIT(30)
552+
553+
#define FBNIC_RPC_ACT_TBL1_DEFAULT 0x0840b /* 0x2102c */
554+
#define FBNIC_RPC_ACT_TBL1_RSS_ENA_MASK CSR_GENMASK(15, 0)
555+
enum {
556+
FBNIC_RPC_ACT_TBL1_RSS_ENA_IP_SRC = 1,
557+
FBNIC_RPC_ACT_TBL1_RSS_ENA_IP_DST = 2,
558+
FBNIC_RPC_ACT_TBL1_RSS_ENA_L4_SRC = 4,
559+
FBNIC_RPC_ACT_TBL1_RSS_ENA_L4_DST = 8,
560+
FBNIC_RPC_ACT_TBL1_RSS_ENA_L2_DA = 16,
561+
FBNIC_RPC_ACT_TBL1_RSS_ENA_L4_RSS_BYTE = 32,
562+
FBNIC_RPC_ACT_TBL1_RSS_ENA_IV6_FL_LBL = 64,
563+
FBNIC_RPC_ACT_TBL1_RSS_ENA_OV6_FL_LBL = 128,
564+
FBNIC_RPC_ACT_TBL1_RSS_ENA_DSCP = 256,
565+
FBNIC_RPC_ACT_TBL1_RSS_ENA_L3_PROT = 512,
566+
FBNIC_RPC_ACT_TBL1_RSS_ENA_L4_PROT = 1024,
567+
};
568+
569+
#define FBNIC_RPC_RSS_KEY(n) (0x0840c + (n)) /* 0x21030 + 4*n */
570+
#define FBNIC_RPC_RSS_KEY_BIT_LEN 425
571+
#define FBNIC_RPC_RSS_KEY_BYTE_LEN \
572+
DIV_ROUND_UP(FBNIC_RPC_RSS_KEY_BIT_LEN, 8)
573+
#define FBNIC_RPC_RSS_KEY_DWORD_LEN \
574+
DIV_ROUND_UP(FBNIC_RPC_RSS_KEY_BIT_LEN, 32)
575+
#define FBNIC_RPC_RSS_KEY_LAST_IDX \
576+
(FBNIC_RPC_RSS_KEY_DWORD_LEN - 1)
577+
#define FBNIC_RPC_RSS_KEY_LAST_MASK \
578+
CSR_GENMASK(31, \
579+
FBNIC_RPC_RSS_KEY_DWORD_LEN * 32 - \
580+
FBNIC_RPC_RSS_KEY_BIT_LEN)
581+
540582
#define FBNIC_RPC_TCAM_MACDA_VALIDATE 0x0852d /* 0x214b4 */
541583
#define FBNIC_CSR_END_RPC 0x0856b /* CSR section delimiter */
542584

543585
/* RPC RAM Registers */
544586

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

548592
/* TCAM Tables */
549593
#define FBNIC_RPC_TCAM_VALIDATE CSR_BIT(31)
594+
595+
/* 64 Action TCAM Entries, 12 registers
596+
* 3 mixed, src port, dst port, 6 L4 words, and Validate
597+
*/
598+
#define FBNIC_RPC_TCAM_ACT(m, n) \
599+
(0x08880 + 0x40 * (n) + (m)) /* 0x22200 + 256*n + 4*m */
600+
601+
#define FBNIC_RPC_TCAM_ACT_VALUE CSR_GENMASK(15, 0)
602+
#define FBNIC_RPC_TCAM_ACT_MASK CSR_GENMASK(31, 16)
603+
550604
#define FBNIC_RPC_TCAM_MACDA(m, n) \
551605
(0x08b80 + 0x20 * (n) + (m)) /* 0x022e00 + 128*n + 4*m */
552606
#define FBNIC_RPC_TCAM_MACDA_VALUE CSR_GENMASK(15, 0)
553607
#define FBNIC_RPC_TCAM_MACDA_MASK CSR_GENMASK(31, 16)
608+
609+
#define FBNIC_RPC_RSS_TBL(n, m) \
610+
(0x08d20 + 0x100 * (n) + (m)) /* 0x023480 + 1024*n + 4*m */
611+
#define FBNIC_RPC_RSS_TBL_COUNT 2
612+
#define FBNIC_RPC_RSS_TBL_SIZE 256
554613
#define FBNIC_CSR_END_RPC_RAM 0x08f1f /* CSR section delimiter */
555614

556615
/* Fab Registers */

drivers/net/ethernet/meta/fbnic/fbnic_netdev.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ int __fbnic_open(struct fbnic_net *fbn)
5050
goto release_ownership;
5151
/* Pull the BMC config and initialize the RPC */
5252
fbnic_bmc_rpc_init(fbd);
53+
fbnic_rss_reinit(fbd, fbn);
5354

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

264265
/* Write updates to hardware */
266+
fbnic_write_rules(fbd);
265267
fbnic_write_macda(fbd);
266268
}
267269

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

401403
fbnic_reset_queues(fbn, default_queues, default_queues);
402404

405+
fbnic_reset_indir_tbl(fbn);
406+
fbnic_rss_key_fill(fbn->rss_key);
407+
fbnic_rss_init_en_mask(fbn);
408+
403409
netdev->features |=
404410
NETIF_F_RXHASH |
405411
NETIF_F_SG |

drivers/net/ethernet/meta/fbnic/fbnic_netdev.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <linux/types.h>
88
#include <linux/phylink.h>
99

10+
#include "fbnic_csr.h"
11+
#include "fbnic_rpc.h"
1012
#include "fbnic_txrx.h"
1113

1214
struct fbnic_net {
@@ -34,7 +36,12 @@ struct fbnic_net {
3436
u16 num_tx_queues;
3537
u16 num_rx_queues;
3638

39+
u8 indir_tbl[FBNIC_RPC_RSS_TBL_COUNT][FBNIC_RPC_RSS_TBL_SIZE];
40+
u32 rss_key[FBNIC_RPC_RSS_KEY_DWORD_LEN];
41+
u32 rss_flow_hash[FBNIC_NUM_HASH_OPT];
42+
3743
u64 link_down_events;
44+
3845
struct list_head napis;
3946
};
4047

drivers/net/ethernet/meta/fbnic/fbnic_pci.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ void fbnic_up(struct fbnic_net *fbn)
133133

134134
fbnic_fill(fbn);
135135

136+
fbnic_rss_reinit_hw(fbn->fbd, fbn);
137+
136138
__fbnic_set_rx_mode(fbn->netdev);
137139

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

153155
fbnic_clear_rx_mode(fbn->netdev);
156+
fbnic_clear_rules(fbn->fbd);
157+
fbnic_rss_disable_hw(fbn->fbd);
154158
fbnic_disable(fbn);
155159
}
156160

0 commit comments

Comments
 (0)