eth: fbnic: support basic RSS config and setting channel count
Subsystems (3)
Jakub Kicinski
maintainercover eth: fbnic: support basic RSS config and setting channel count
Add support for basic RSS config (indirection table, key get and set), and changing the number of channels.
# ./ksft-net-drv/run_kselftest.sh -t drivers/net/hw:rss_ctx.py TAP version 13 1..1 # timeout set to 0 # selftests: drivers/net/hw: rss_ctx.py # KTAP version 1 # 1..15 # ok 1 rss_ctx.test_rss_key_indir # ok 2 rss_ctx.test_rss_queue_reconfigure # ok 3 rss_ctx.test_rss_resize # ok 4 rss_ctx.test_hitless_key_update
.. the rest of the tests are for additional contexts so they get skipped..
The slicing of the patches (and bugs) are mine, but I'm keeping Alex as the author on the patches where he wrote 100% of the code.
Alexander Duyck (4):
eth: fbnic: support querying RSS config
eth: fbnic: support setting RSS configuration
eth: fbnic: let user control the RSS hash fields
eth: fbnic: centralize the queue count and NAPI<>queue setting
Jakub Kicinski (6):
eth: fbnic: reorder ethtool code
eth: fbnic: don't reset the secondary RSS indir table
eth: fbnic: store NAPIs in an array instead of the list
eth: fbnic: add IRQ reuse support
eth: fbnic: support ring channel get and set while down
eth: fbnic: support ring channel set while up
drivers/net/ethernet/meta/fbnic/fbnic.h | 15 + .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 551 +++++++++++++++--- drivers/net/ethernet/meta/fbnic/fbnic_irq.c | 53 ++ .../net/ethernet/meta/fbnic/fbnic_netdev.c | 12 +- .../net/ethernet/meta/fbnic/fbnic_netdev.h | 7 +- drivers/net/ethernet/meta/fbnic/fbnic_pci.c | 2 +- drivers/net/ethernet/meta/fbnic/fbnic_rpc.c | 7 +- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 236 ++++---- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 16 +- 9 files changed, 699 insertions(+), 200 deletions(-)
Signature · 1 line
2.47.1
Jakub Kicinski
maintainerPATCH 1/10 eth: fbnic: reorder ethtool code
Define ethtool callback handlers in order in which they are defined in the ops struct. It doesn't really matter what the order is, but it's good to have an order.
--- .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 160 +++++++++--------- 1 file changed, 80 insertions(+), 80 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +80 -80
@@ -40,6 +40,68 @@ static const struct fbnic_stat fbnic_gstrings_hw_stats[] = {#define FBNIC_HW_FIXED_STATS_LEN ARRAY_SIZE(fbnic_gstrings_hw_stats)#define FBNIC_HW_STATS_LEN FBNIC_HW_FIXED_STATS_LEN +static void +fbnic_get_drvinfo (struct net_device *netdev,struct ethtool_drvinfo *drvinfo) +{ +struct fbnic_net *fbn =netdev_priv (netdev); +struct fbnic_dev *fbd = fbn->fbd; + +fbnic_get_fw_ver_commit_str (fbd, drvinfo->fw_version, +sizeof (drvinfo->fw_version)); +} + +static int fbnic_get_regs_len (struct net_device *netdev) +{ +struct fbnic_net *fbn =netdev_priv (netdev); + +return fbnic_csr_regs_len (fbn->fbd) *sizeof (u32); +} + +static void fbnic_get_regs (struct net_device *netdev, +struct ethtool_regs *regs,void *data) +{ +struct fbnic_net *fbn =netdev_priv (netdev); + +fbnic_csr_get_regs (fbn->fbd, data, ®s->version); +} + +static void fbnic_get_strings (struct net_device *dev,u32 sset,u8 *data) +{ +int i; + +switch (sset) { +case ETH_SS_STATS : +for (i =0 ; i <FBNIC_HW_STATS_LEN ; i++) +ethtool_puts (&data, fbnic_gstrings_hw_stats[i].string); +break ; + } +} + +static void fbnic_get_ethtool_stats (struct net_device *dev, +struct ethtool_stats *stats,u64 *data) +{ +struct fbnic_net *fbn =netdev_priv (dev); +const struct fbnic_stat *stat; +int i; + +fbnic_get_hw_stats (fbn->fbd); + +for (i =0 ; i <FBNIC_HW_STATS_LEN ; i++) { + stat = &fbnic_gstrings_hw_stats[i]; + data[i] = *(u64 *)((u8 *)&fbn->fbd->hw_stats + stat->offset); + } +} + +static int fbnic_get_sset_count (struct net_device *dev,int sset) +{ +switch (sset) { +case ETH_SS_STATS : +return FBNIC_HW_STATS_LEN ; +default : +return -EOPNOTSUPP ; + } +} +static int fbnic_get_ts_info (struct net_device *netdev,struct kernel_ethtool_ts_info *tsinfo)
@@ -69,14 +131,27 @@ fbnic_get_ts_info(struct net_device *netdev,return 0 ; } -static void -fbnic_get_drvinfo (struct net_device *netdev,struct ethtool_drvinfo *drvinfo) +static void fbnic_get_ts_stats (struct net_device *netdev, +struct ethtool_ts_stats *ts_stats) {struct fbnic_net *fbn =netdev_priv (netdev); -struct fbnic_dev *fbd = fbn->fbd; +u64 ts_packets, ts_lost; +struct fbnic_ring *ring; +unsigned int start; +int i; -fbnic_get_fw_ver_commit_str (fbd, drvinfo->fw_version, -sizeof (drvinfo->fw_version)); + ts_stats->pkts = fbn->tx_stats.ts_packets; + ts_stats->lost = fbn->tx_stats.ts_lost; +for (i =0 ; i < fbn->num_tx_queues; i++) { + ring = fbn->tx[i]; +do { + start =u64_stats_fetch_begin (&ring->stats.syncp); + ts_packets = ring->stats.ts_packets; + ts_lost = ring->stats.ts_lost; + }while (u64_stats_fetch_retry (&ring->stats.syncp, start)); + ts_stats->pkts += ts_packets; + ts_stats->lost += ts_lost; + } }static void fbnic_set_counter (u64 *stat,struct fbnic_stat_counter *counter)
@@ -85,43 +160,6 @@ static void fbnic_set_counter(u64 *stat, struct fbnic_stat_counter *counter) *stat = counter->value; } -static void fbnic_get_strings (struct net_device *dev,u32 sset,u8 *data) -{ -int i; - -switch (sset) { -case ETH_SS_STATS : -for (i =0 ; i <FBNIC_HW_STATS_LEN ; i++) -ethtool_puts (&data, fbnic_gstrings_hw_stats[i].string); -break ; - } -} - -static int fbnic_get_sset_count (struct net_device *dev,int sset) -{ -switch (sset) { -case ETH_SS_STATS : -return FBNIC_HW_STATS_LEN ; -default : -return -EOPNOTSUPP ; - } -} - -static void fbnic_get_ethtool_stats (struct net_device *dev, -struct ethtool_stats *stats,u64 *data) -{ -struct fbnic_net *fbn =netdev_priv (dev); -const struct fbnic_stat *stat; -int i; - -fbnic_get_hw_stats (fbn->fbd); - -for (i =0 ; i <FBNIC_HW_STATS_LEN ; i++) { - stat = &fbnic_gstrings_hw_stats[i]; - data[i] = *(u64 *)((u8 *)&fbn->fbd->hw_stats + stat->offset); - } -} -static void fbnic_get_eth_mac_stats (struct net_device *netdev,struct ethtool_eth_mac_stats *eth_mac_stats)
@@ -164,44 +202,6 @@ fbnic_get_eth_mac_stats(struct net_device *netdev, &mac_stats->eth_mac.FrameTooLongErrors); } -static void fbnic_get_ts_stats (struct net_device *netdev, -struct ethtool_ts_stats *ts_stats) -{ -struct fbnic_net *fbn =netdev_priv (netdev); -u64 ts_packets, ts_lost; -struct fbnic_ring *ring; -unsigned int start; -int i; - - ts_stats->pkts = fbn->tx_stats.ts_packets; - ts_stats->lost = fbn->tx_stats.ts_lost; -for (i =0 ; i < fbn->num_tx_queues; i++) { - ring = fbn->tx[i]; -do { - start =u64_stats_fetch_begin (&ring->stats.syncp); - ts_packets = ring->stats.ts_packets; - ts_lost = ring->stats.ts_lost; - }while (u64_stats_fetch_retry (&ring->stats.syncp, start)); - ts_stats->pkts += ts_packets; - ts_stats->lost += ts_lost; - } -} - -static void fbnic_get_regs (struct net_device *netdev, -struct ethtool_regs *regs,void *data) -{ -struct fbnic_net *fbn =netdev_priv (netdev); - -fbnic_csr_get_regs (fbn->fbd, data, ®s->version); -} - -static int fbnic_get_regs_len (struct net_device *netdev) -{ -struct fbnic_net *fbn =netdev_priv (netdev); - -return fbnic_csr_regs_len (fbn->fbd) *sizeof (u32); -} -static const struct ethtool_ops fbnic_ethtool_ops = { .get_drvinfo = fbnic_get_drvinfo, .get_regs_len = fbnic_get_regs_len,
Signature · 1 line
2.47.1
Re: [PATCH net-next 01/10] eth: fbnic: reorder ethtool code
Quoted 14 lines · Jakub Kicinski
Define ethtool callback handlers in order in which they are defined in the ops struct. It doesn't really matter what the order is, but it's good to have an order.
Signed-off-by Jakub Kicinski <[email protected]>--- .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 160 +++++++++--------- 1 file changed, 80 insertions(+), 80 deletions(-)drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +0
-0
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c static const struct fbnic_stat fbnic_gstrings_hw_stats[] = { · line 43
Quoted 4 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +1
-0@@ -40,6 +40,68 @@ static const struct fbnic_stat fbnic_gstrings_hw_stats[] = {#define FBNIC_HW_FIXED_STATS_LEN ARRAY_SIZE(fbnic_gstrings_hw_stats)#define FBNIC_HW_STATS_LEN FBNIC_HW_FIXED_STATS_LEN +static void
I thought type and name on separate lines are not desirable, it could be moved to a single line in this commit. Assuming such adjustment,
Also, this would be a little bit out of scope for this commit, but seeing relatively new code that does not use for (int i = 0,...) is surprising.
Quoted 190 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +79
-80+fbnic_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) +{ + struct fbnic_net *fbn = netdev_priv(netdev); +struct fbnic_dev *fbd = fbn->fbd; + +fbnic_get_fw_ver_commit_str (fbd, drvinfo->fw_version, +sizeof (drvinfo->fw_version)); +} + +static int fbnic_get_regs_len (struct net_device *netdev) +{ +struct fbnic_net *fbn =netdev_priv (netdev); + +return fbnic_csr_regs_len (fbn->fbd) *sizeof (u32); +} + +static void fbnic_get_regs (struct net_device *netdev, +struct ethtool_regs *regs,void *data) +{ +struct fbnic_net *fbn =netdev_priv (netdev); + +fbnic_csr_get_regs (fbn->fbd, data, ®s->version); +} + +static void fbnic_get_strings (struct net_device *dev,u32 sset,u8 *data) +{ +int i; + +switch (sset) { +case ETH_SS_STATS : +for (i =0 ; i <FBNIC_HW_STATS_LEN ; i++) +ethtool_puts (&data, fbnic_gstrings_hw_stats[i].string); +break ; + } +} + +static void fbnic_get_ethtool_stats (struct net_device *dev, +struct ethtool_stats *stats,u64 *data) +{ +struct fbnic_net *fbn =netdev_priv (dev); +const struct fbnic_stat *stat; +int i; + +fbnic_get_hw_stats (fbn->fbd); + +for (i =0 ; i <FBNIC_HW_STATS_LEN ; i++) { + stat = &fbnic_gstrings_hw_stats[i]; + data[i] = *(u64 *)((u8 *)&fbn->fbd->hw_stats + stat->offset); + } +} + +static int fbnic_get_sset_count (struct net_device *dev,int sset) +{ +switch (sset) { +case ETH_SS_STATS : +return FBNIC_HW_STATS_LEN ; +default : +return -EOPNOTSUPP ; + } +} +static int fbnic_get_ts_info (struct net_device *netdev,struct kernel_ethtool_ts_info *tsinfo)@@ -69,14 +131,27 @@ fbnic_get_ts_info(struct net_device *netdev,return 0 ; } -static void -fbnic_get_drvinfo (struct net_device *netdev,struct ethtool_drvinfo *drvinfo) +static void fbnic_get_ts_stats (struct net_device *netdev, +struct ethtool_ts_stats *ts_stats) {struct fbnic_net *fbn =netdev_priv (netdev); -struct fbnic_dev *fbd = fbn->fbd; +u64 ts_packets, ts_lost; +struct fbnic_ring *ring; +unsigned int start; +int i; -fbnic_get_fw_ver_commit_str (fbd, drvinfo->fw_version, -sizeof (drvinfo->fw_version)); + ts_stats->pkts = fbn->tx_stats.ts_packets; + ts_stats->lost = fbn->tx_stats.ts_lost; +for (i =0 ; i < fbn->num_tx_queues; i++) { + ring = fbn->tx[i]; +do { + start =u64_stats_fetch_begin (&ring->stats.syncp); + ts_packets = ring->stats.ts_packets; + ts_lost = ring->stats.ts_lost; + }while (u64_stats_fetch_retry (&ring->stats.syncp, start)); + ts_stats->pkts += ts_packets; + ts_stats->lost += ts_lost; + } }static void fbnic_set_counter (u64 *stat,struct fbnic_stat_counter *counter)@@ -85,43 +160,6 @@ static void fbnic_set_counter(u64 *stat, struct fbnic_stat_counter *counter) *stat = counter->value; } -static void fbnic_get_strings (struct net_device *dev,u32 sset,u8 *data) -{ -int i; - -switch (sset) { -case ETH_SS_STATS : -for (i =0 ; i <FBNIC_HW_STATS_LEN ; i++) -ethtool_puts (&data, fbnic_gstrings_hw_stats[i].string); -break ; - } -} - -static int fbnic_get_sset_count (struct net_device *dev,int sset) -{ -switch (sset) { -case ETH_SS_STATS : -return FBNIC_HW_STATS_LEN ; -default : -return -EOPNOTSUPP ; - } -} - -static void fbnic_get_ethtool_stats (struct net_device *dev, -struct ethtool_stats *stats,u64 *data) -{ -struct fbnic_net *fbn =netdev_priv (dev); -const struct fbnic_stat *stat; -int i; - -fbnic_get_hw_stats (fbn->fbd); - -for (i =0 ; i <FBNIC_HW_STATS_LEN ; i++) { - stat = &fbnic_gstrings_hw_stats[i]; - data[i] = *(u64 *)((u8 *)&fbn->fbd->hw_stats + stat->offset); - } -} -static void fbnic_get_eth_mac_stats (struct net_device *netdev,struct ethtool_eth_mac_stats *eth_mac_stats)@@ -164,44 +202,6 @@ fbnic_get_eth_mac_stats(struct net_device *netdev, &mac_stats->eth_mac.FrameTooLongErrors); } -static void fbnic_get_ts_stats (struct net_device *netdev, -struct ethtool_ts_stats *ts_stats) -{ -struct fbnic_net *fbn =netdev_priv (netdev); -u64 ts_packets, ts_lost; -struct fbnic_ring *ring; -unsigned int start; -int i; - - ts_stats->pkts = fbn->tx_stats.ts_packets; - ts_stats->lost = fbn->tx_stats.ts_lost; -for (i =0 ; i < fbn->num_tx_queues; i++) { - ring = fbn->tx[i]; -do { - start =u64_stats_fetch_begin (&ring->stats.syncp); - ts_packets = ring->stats.ts_packets; - ts_lost = ring->stats.ts_lost; - }while (u64_stats_fetch_retry (&ring->stats.syncp, start)); - ts_stats->pkts += ts_packets; - ts_stats->lost += ts_lost; - } -} - -static void fbnic_get_regs (struct net_device *netdev, -struct ethtool_regs *regs,void *data) -{ -struct fbnic_net *fbn =netdev_priv (netdev); - -fbnic_csr_get_regs (fbn->fbd, data, ®s->version); -} - -static int fbnic_get_regs_len (struct net_device *netdev) -{ -struct fbnic_net *fbn =netdev_priv (netdev); - -return fbnic_csr_regs_len (fbn->fbd) *sizeof (u32); -} -static const struct ethtool_ops fbnic_ethtool_ops = { .get_drvinfo = fbnic_get_drvinfo, .get_regs_len = fbnic_get_regs_len,Signature · 1 line
2.47.1
Jakub Kicinski
maintainerRe: [PATCH net-next 01/10] eth: fbnic: reorder ethtool code
Quoted 2 lines · On Fri, 20 Dec 2024 15:53:18 +0100 Larysa Zaremba wrote:
I thought type and name on separate lines are not desirable, it could be moved to a single line in this commit. Assuming such adjustment,
I find this style more readable, TBH. I tend to break the line after return type if the function declaration doesn't fit on a line and the type is longer than 3 chars (IOW int/u32/u8 are exceptions).
Functions which end up looking like:
static struct some_type_struct *some_function_name_here(struct another *ptr,
int argument);
are really ugly. And break if > 3 chars is a simple rule to follow.
You will find that most of fbnic does not follow this style, because I didn't write most of it. But most of the nfp driver does.
I think I learned the breaking after return type from Felix Fietkau. Not that he specified the 3 character thing as pedantically as I do.
Quoted 4 lines
Reviewed-by Larysa Zaremba <[email protected]>Also, this would be a little bit out of scope for this commit, but seeing relatively new code that does not use
for (int i = 0,...)is surprising.
I think you at Intel try to adopt the novelties much more than the rest of us. Let us old timers be, please.
Jakub Kicinski
maintainerPATCH 2/10 eth: fbnic: support querying RSS config
In reply to Jakub KicinskiFrom: Alexander Duyck <[email protected]>
The initial driver submission already added all the RSS state, as part of multi-queue support. Expose the configuration via the ethtool APIs.
--- .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+)
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +103 -0
@@ -102,6 +102,105 @@ static int fbnic_get_sset_count(struct net_device *dev, int sset) } } +static int fbnic_get_rss_hash_idx (u32 flow_type) +{ +switch (flow_type & ~(FLOW_EXT |FLOW_MAC_EXT |FLOW_RSS )) { +case TCP_V4_FLOW : +return FBNIC_TCP4_HASH_OPT ; +case TCP_V6_FLOW : +return FBNIC_TCP6_HASH_OPT ; +case UDP_V4_FLOW : +return FBNIC_UDP4_HASH_OPT ; +case UDP_V6_FLOW : +return FBNIC_UDP6_HASH_OPT ; +case AH_V4_FLOW : +case ESP_V4_FLOW : +case AH_ESP_V4_FLOW : +case SCTP_V4_FLOW : +case IPV4_FLOW : +case IPV4_USER_FLOW : +return FBNIC_IPV4_HASH_OPT ; +case AH_V6_FLOW : +case ESP_V6_FLOW : +case AH_ESP_V6_FLOW : +case SCTP_V6_FLOW : +case IPV6_FLOW : +case IPV6_USER_FLOW : +return FBNIC_IPV6_HASH_OPT ; +case ETHER_FLOW : +return FBNIC_ETHER_HASH_OPT ; + } + +return -1 ; +} + +static int +fbnic_get_rss_hash_opts (struct fbnic_net *fbn,struct ethtool_rxnfc *cmd) +{ +int hash_opt_idx =fbnic_get_rss_hash_idx (cmd->flow_type); + +if (hash_opt_idx <0 ) +return -EINVAL ; + +/* Report options from rss_en table in fbn */ + cmd->data = fbn->rss_flow_hash[hash_opt_idx]; + +return 0 ; +} + +static int fbnic_get_rxnfc (struct net_device *netdev, +struct ethtool_rxnfc *cmd,u32 *rule_locs) +{ +struct fbnic_net *fbn =netdev_priv (netdev); +int ret = -EOPNOTSUPP ; + +switch (cmd->cmd) { +case ETHTOOL_GRXRINGS : + cmd->data = fbn->num_rx_queues; + ret =0 ; +break ; +case ETHTOOL_GRXFH : + ret =fbnic_get_rss_hash_opts (fbn, cmd); +break ; + } + +return ret; +} + +static u32 fbnic_get_rxfh_key_size (struct net_device *netdev) +{ +return FBNIC_RPC_RSS_KEY_BYTE_LEN ; +} + +static u32 fbnic_get_rxfh_indir_size (struct net_device *netdev) +{ +return FBNIC_RPC_RSS_TBL_SIZE ; +} + +static int +fbnic_get_rxfh (struct net_device *netdev,struct ethtool_rxfh_param *rxfh) +{ +struct fbnic_net *fbn =netdev_priv (netdev); +unsigned int i; + + rxfh->hfunc =ETH_RSS_HASH_TOP ; + +if (rxfh->key) { +for (i =0 ; i <FBNIC_RPC_RSS_KEY_BYTE_LEN ; i++) { +u32 rss_key = fbn->rss_key[i /4 ] << ((i %4 ) *8 ); + + rxfh->key[i] = rss_key >>24 ; + } + } + +if (rxfh->indir) { +for (i =0 ; i <FBNIC_RPC_RSS_TBL_SIZE ; i++) + rxfh->indir[i] = fbn->indir_tbl[0 ][i]; + } + +return 0 ; +} +static int fbnic_get_ts_info (struct net_device *netdev,struct kernel_ethtool_ts_info *tsinfo)
@@ -209,6 +308,10 @@ static const struct ethtool_ops fbnic_ethtool_ops = { .get_strings = fbnic_get_strings, .get_ethtool_stats = fbnic_get_ethtool_stats, .get_sset_count = fbnic_get_sset_count, + .get_rxnfc = fbnic_get_rxnfc, + .get_rxfh_key_size = fbnic_get_rxfh_key_size, + .get_rxfh_indir_size = fbnic_get_rxfh_indir_size, + .get_rxfh = fbnic_get_rxfh, .get_ts_info = fbnic_get_ts_info, .get_ts_stats = fbnic_get_ts_stats, .get_eth_mac_stats = fbnic_get_eth_mac_stats,
Signature · 1 line
2.47.1
Re: [PATCH net-next 02/10] eth: fbnic: support querying RSS config
Quoted 14 lines · Jakub Kicinski
From: Alexander Duyck <[email protected]>
The initial driver submission already added all the RSS state, as part of multi-queue support. Expose the configuration via the ethtool APIs.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>--- .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+)
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c static int fbnic_get_sset_count(struct net_device *dev, int sset) · line 184
Quoted 5 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +5
-0+static int +fbnic_get_rxfh (struct net_device *netdev,struct ethtool_rxfh_param *rxfh) +{ +struct fbnic_net *fbn =netdev_priv (netdev); +unsigned int i;
AFAIK index type should be spelled as u32
And will be best declared in the first clause of the for()
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c static int fbnic_get_sset_count(struct net_device *dev, int sset) · line 190
Quoted 6 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +6
-0+ + rxfh->hfunc =ETH_RSS_HASH_TOP ; + +if (rxfh->key) { +for (i =0 ; i <FBNIC_RPC_RSS_KEY_BYTE_LEN ; i++) { +u32 rss_key = fbn->rss_key[i /4 ] << ((i %4 ) *8 );
are you dropping 75% of entropy provided in fbn->rss_key?
Quoted 27 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +17
-0+ + rxfh->key[i] = rss_key >>24 ; + } + } + +if (rxfh->indir) { +for (i =0 ; i <FBNIC_RPC_RSS_TBL_SIZE ; i++) + rxfh->indir[i] = fbn->indir_tbl[0 ][i]; + } + +return 0 ; +} +static int fbnic_get_ts_info (struct net_device *netdev,struct kernel_ethtool_ts_info *tsinfo)@@ -209,6 +308,10 @@ static const struct ethtool_ops fbnic_ethtool_ops = { .get_strings = fbnic_get_strings, .get_ethtool_stats = fbnic_get_ethtool_stats, .get_sset_count = fbnic_get_sset_count, + .get_rxnfc = fbnic_get_rxnfc, + .get_rxfh_key_size = fbnic_get_rxfh_key_size, + .get_rxfh_indir_size = fbnic_get_rxfh_indir_size, + .get_rxfh = fbnic_get_rxfh, .get_ts_info = fbnic_get_ts_info, .get_ts_stats = fbnic_get_ts_stats, .get_eth_mac_stats = fbnic_get_eth_mac_stats,
Jakub Kicinski
maintainerRe: [PATCH net-next 02/10] eth: fbnic: support querying RSS config
Quoted 7 lines · On Fri, 20 Dec 2024 12:42:42 +0100 Przemek Kitszel wrote:
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c static int fbnic_get_sset_count(struct net_device *dev, int sset) · line 184
Quoted 5 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +5
-0+static int +fbnic_get_rxfh (struct net_device *netdev,struct ethtool_rxfh_param *rxfh) +{ +struct fbnic_net *fbn =netdev_priv (netdev); +unsigned int i;AFAIK index type should be spelled as u32
Does it matter? I have a weak preference for not using explicitly sized types unless the bit width is itself meaningful.
Quoted 1 line
And will be best declared in the first clause of the
for()
I don't see woohaii.
Quoted 8 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c static int fbnic_get_sset_count(struct net_device *dev, int sset) · line 190
Quoted 6 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +6
-0+ + rxfh->hfunc =ETH_RSS_HASH_TOP ; + +if (rxfh->key) { +for (i =0 ; i <FBNIC_RPC_RSS_KEY_BYTE_LEN ; i++) { +u32 rss_key = fbn->rss_key[i /4 ] << ((i %4 ) *8 );are you dropping 75% of entropy provided in
fbn->rss_key?
Nope, it's shifting out the unused bits. And below we shift back down to the lowest byte.
We store the key as u32 (register width) while the uAPI is in u8.
Quoted 11 lines
Quoted 11 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +11
-0+ + rxfh->key[i] = rss_key >>24 ; + } + } + +if (rxfh->indir) { +for (i =0 ; i <FBNIC_RPC_RSS_TBL_SIZE ; i++) + rxfh->indir[i] = fbn->indir_tbl[0 ][i]; + } + +return 0 ;
Przemek Kitszel
Reviewed-byRe: [PATCH net-next 02/10] eth: fbnic: support querying RSS config
Quoted 1 line · Jakub Kicinski
On Fri, 20 Dec 2024 12:42:42 +0100 Przemek Kitszel wrote:
with [1] this patch looks good to me, thank you for explanation:
the rest of the series is also fine for me, but I didn't spend that much time to inflate my RB count
Quoted 10 lines
Quoted 7 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c static int fbnic_get_sset_count(struct net_device *dev, int sset) · line 184
Quoted 5 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +5
-0+static int +fbnic_get_rxfh (struct net_device *netdev,struct ethtool_rxfh_param *rxfh) +{ +struct fbnic_net *fbn =netdev_priv (netdev); +unsigned int i;AFAIK index type should be spelled as u32
Does it matter? I have a weak preference for not using explicitly sized types unless the bit width is itself meaningful.
me too, unless it is "unsiged int", but I', not gonna fight for it
I would say that plain int is fine for iterator unless you want to explicitly get the non-UB wrap-around (or count more than 31 bit wide). But again, does not matter
Quoted 4 lines
Quoted 2 lines
And will be best declared in the first clause of the
for()I don't see woohaii.
with such long to type types, it would be inconvenient, but the usual argument about the proper scope of the variable
Quoted 10 lines
Quoted 9 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c static int fbnic_get_sset_count(struct net_device *dev, int sset) · line 190
Quoted 7 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +6
-0+ + rxfh->hfunc =ETH_RSS_HASH_TOP ; + +if (rxfh->key) { +for (i =0 ; i <FBNIC_RPC_RSS_KEY_BYTE_LEN ; i++) { +u32 rss_key = fbn->rss_key[i /4 ] << ((i %4 ) *8 );are you dropping 75% of entropy provided in
fbn->rss_key?
Quoted 3 lines
Nope, it's shifting out the unused bits. And below we shift back down to the lowest byte.
We store the key as u32 (register width) while the uAPI is in u8.
[1]
OK, I've double checked and the fbn->rss_key array has indeed FBNIC_RPC_RSS_KEY_BYTE_LEN/4 entries
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +11
-0+ + rxfh->key[i] = rss_key >>24 ; + } + } + +if (rxfh->indir) { +for (i =0 ; i <FBNIC_RPC_RSS_TBL_SIZE ; i++) + rxfh->indir[i] = fbn->indir_tbl[0 ][i]; + } + +return 0 ;
Jakub Kicinski
maintainerPATCH 3/10 eth: fbnic: don't reset the secondary RSS indir table
In reply to Jakub KicinskiSecondary RSS indirection table is for additional contexts. It can / should be initialized when such context is created. Since we don't support creating RSS contexts, yet, this change has no user visible effect.
--- drivers/net/ethernet/meta/fbnic/fbnic_rpc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_rpc.c +1 -3
@@ -13,10 +13,8 @@ void fbnic_reset_indir_tbl(struct fbnic_net *fbn)unsigned int num_rx = fbn->num_rx_queues;unsigned int i; -for (i =0 ; i <FBNIC_RPC_RSS_TBL_SIZE ; i++) { +for (i =0 ; i <FBNIC_RPC_RSS_TBL_SIZE ; i++) fbn->indir_tbl[0 ][i] =ethtool_rxfh_indir_default (i, num_rx); - fbn->indir_tbl[1 ][i] =ethtool_rxfh_indir_default (i, num_rx); - } }void fbnic_rss_key_fill (u32 *buffer)
Signature · 1 line
2.47.1
Jakub Kicinski
maintainerPATCH 4/10 eth: fbnic: support setting RSS configuration
In reply to Jakub KicinskiFrom: Alexander Duyck <[email protected]>
Let the user program the RSS indirection table and the RSS key. Straightforward implementation. Track the changes and don't bother poking the HW if user asked for a config identical to what's already programmed. The device only supports Toeplitz hash.
Similarly to the GET support - all the real code that does the programming was part of initial driver submission, already.
--- .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+)
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +55 -0
@@ -201,6 +201,60 @@ fbnic_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh)return 0 ; } +static unsigned int +fbnic_set_indir (struct fbnic_net *fbn,unsigned int idx,const u32 *indir) +{ +unsigned int i, changes =0 ; + +for (i =0 ; i <FBNIC_RPC_RSS_TBL_SIZE ; i++) { +if (fbn->indir_tbl[idx][i] == indir[i]) +continue ; + + fbn->indir_tbl[idx][i] = indir[i]; + changes++; + } + +return changes; +} + +static int +fbnic_set_rxfh (struct net_device *netdev,struct ethtool_rxfh_param *rxfh, +struct netlink_ext_ack *extack) +{ +struct fbnic_net *fbn =netdev_priv (netdev); +unsigned int i, changes =0 ; + +if (rxfh->hfunc !=ETH_RSS_HASH_NO_CHANGE && + rxfh->hfunc !=ETH_RSS_HASH_TOP ) +return -EINVAL ; + +if (rxfh->key) { +u32 rss_key =0 ; + +for (i =FBNIC_RPC_RSS_KEY_BYTE_LEN ; i--;) { + rss_key >>=8 ; + rss_key |= (u32)(rxfh->key[i]) <<24 ; + +if (i %4 ) +continue ; + +if (fbn->rss_key[i /4 ] == rss_key) +continue ; + + fbn->rss_key[i /4 ] = rss_key; + changes++; + } + } + +if (rxfh->indir) + changes +=fbnic_set_indir (fbn,0 , rxfh->indir); + +if (changes &&netif_running (netdev)) +fbnic_rss_reinit_hw (fbn->fbd, fbn); + +return 0 ; +} +static int fbnic_get_ts_info (struct net_device *netdev,struct kernel_ethtool_ts_info *tsinfo)
@@ -312,6 +366,7 @@ static const struct ethtool_ops fbnic_ethtool_ops = { .get_rxfh_key_size = fbnic_get_rxfh_key_size, .get_rxfh_indir_size = fbnic_get_rxfh_indir_size, .get_rxfh = fbnic_get_rxfh, + .set_rxfh = fbnic_set_rxfh, .get_ts_info = fbnic_get_ts_info, .get_ts_stats = fbnic_get_ts_stats, .get_eth_mac_stats = fbnic_get_eth_mac_stats,
Signature · 1 line
2.47.1
Jakub Kicinski
maintainerPATCH 5/10 eth: fbnic: let user control the RSS hash fields
In reply to Jakub KicinskiFrom: Alexander Duyck <[email protected]>
Support setting the fields over which RSS computes its hash.
--- .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+)
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +50 -0
@@ -167,6 +167,55 @@ static int fbnic_get_rxnfc(struct net_device *netdev,return ret; } +#define FBNIC_L2_HASH_OPTIONS \ + (RXH_L2DA | RXH_DISCARD) +#define FBNIC_L3_HASH_OPTIONS \ + (FBNIC_L2_HASH_OPTIONS | RXH_IP_SRC | RXH_IP_DST) +#define FBNIC_L4_HASH_OPTIONS \ + (FBNIC_L3_HASH_OPTIONS | RXH_L4_B_0_1 | RXH_L4_B_2_3) + +static int +fbnic_set_rss_hash_opts (struct fbnic_net *fbn,const struct ethtool_rxnfc *cmd) +{ +int hash_opt_idx; + +/* Verify the type requested is correct */ + hash_opt_idx =fbnic_get_rss_hash_idx (cmd->flow_type); +if (hash_opt_idx <0 ) +return -EINVAL ; + +/* Verify the fields asked for can actually be assigned based on type */ +if (cmd->data & ~FBNIC_L4_HASH_OPTIONS || + (hash_opt_idx >FBNIC_L4_HASH_OPT && + cmd->data & ~FBNIC_L3_HASH_OPTIONS ) || + (hash_opt_idx >FBNIC_IP_HASH_OPT && + cmd->data & ~FBNIC_L2_HASH_OPTIONS )) +return -EINVAL ; + + fbn->rss_flow_hash[hash_opt_idx] = cmd->data; + +if (netif_running (fbn->netdev)) { +fbnic_rss_reinit (fbn->fbd, fbn); +fbnic_write_rules (fbn->fbd); + } + +return 0 ; +} + +static int fbnic_set_rxnfc (struct net_device *netdev,struct ethtool_rxnfc *cmd) +{ +struct fbnic_net *fbn =netdev_priv (netdev); +int ret = -EOPNOTSUPP ; + +switch (cmd->cmd) { +case ETHTOOL_SRXFH : + ret =fbnic_set_rss_hash_opts (fbn, cmd); +break ; + } + +return ret; +} +static u32 fbnic_get_rxfh_key_size (struct net_device *netdev) {return FBNIC_RPC_RSS_KEY_BYTE_LEN ;
@@ -363,6 +412,7 @@ static const struct ethtool_ops fbnic_ethtool_ops = { .get_ethtool_stats = fbnic_get_ethtool_stats, .get_sset_count = fbnic_get_sset_count, .get_rxnfc = fbnic_get_rxnfc, + .set_rxnfc = fbnic_set_rxnfc, .get_rxfh_key_size = fbnic_get_rxfh_key_size, .get_rxfh_indir_size = fbnic_get_rxfh_indir_size, .get_rxfh = fbnic_get_rxfh,
Signature · 1 line
2.47.1
Jakub Kicinski
maintainerPATCH 6/10 eth: fbnic: store NAPIs in an array instead of the list
In reply to Jakub KicinskiWe will need an array for storing NAPIs in the upcoming IRQ handler reuse rework. Replace the current list we have, so that we are able to reuse it later.
In a few places replace i as the iterator with t when we iterate over triads, this seems slightly less confusing than having i, j, k variables.
--- .../net/ethernet/meta/fbnic/fbnic_netdev.c | 1 - .../net/ethernet/meta/fbnic/fbnic_netdev.h | 6 +- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 117 ++++++++++-------- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 7 +- 4 files changed, 71 insertions(+), 60 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +0 -1
@@ -615,7 +615,6 @@ struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd) fbn->netdev = netdev; fbn->fbd = fbd; -INIT_LIST_HEAD (&fbn->napis); fbn->txq_size =FBNIC_TXQ_SIZE_DEFAULT ; fbn->hpq_size =FBNIC_HPQ_SIZE_DEFAULT ;
drivers/net/ethernet/meta/fbnic/fbnic_netdev.h +4 -2
@@ -11,10 +11,14 @@#include "fbnic_rpc.h" #include "fbnic_txrx.h" +#define FBNIC_MAX_NAPI_VECTORS 128u +struct fbnic_net {struct fbnic_ring *tx[FBNIC_MAX_TXQS ];struct fbnic_ring *rx[FBNIC_MAX_RXQS ]; +struct fbnic_napi_vector *napi[FBNIC_MAX_NAPI_VECTORS ]; +struct net_device *netdev;struct fbnic_dev *fbd;
@@ -56,8 +60,6 @@ struct fbnic_net {/* Time stampinn filter config */ struct kernel_hwtstamp_config hwtstamp_config; - -struct list_head napis; };int __fbnic_open (struct fbnic_net *fbn);
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +62 -55
244 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +5 -2
@@ -110,8 +110,6 @@ struct fbnic_napi_vector {u8 txt_count;u8 rxt_count; -struct list_head napis; -struct fbnic_q_triad qt[]; };
@@ -137,4 +135,9 @@ 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); +static inline int fbnic_napi_idx (const struct fbnic_napi_vector *nv) +{ +return nv->v_idx -FBNIC_NON_NAPI_VECTORS ; +} +#endif /* _FBNIC_TXRX_H_ */
Signature · 1 line
2.47.1
Jakub Kicinski
maintainerPATCH 7/10 eth: fbnic: add IRQ reuse support
In reply to Jakub KicinskiChange our method of swapping NAPIs without disturbing existing config. This is primarily needed for "live reconfiguration" such as changing the channel count when interface is already up.
Previously we were planning to use a trick of using shared interrupts. We would install a second IRQ handler for the new NAPI, and make it return IRQ_NONE until we were ready for it to take over. This works fine functionally but breaks IRQ naming. The IRQ subsystem uses the IRQ name to create the procfs entry, since both handlers used the same name the second handler wouldn't get a proc directory registered. When first one gets removed on success full ring count change it would remove its directory and we would be left with none.
New approach uses a double pointer to the NAPI. The IRQ handler needs to know how to locate the NAPI to schedule. We register a single IRQ handler and give it a pointer to a pointer. We can then change what it points to without re-registering. This may have a tiny perf impact, but really really negligible.
--- drivers/net/ethernet/meta/fbnic/fbnic.h | 14 +++++++ drivers/net/ethernet/meta/fbnic/fbnic_irq.c | 42 +++++++++++++++++++ .../net/ethernet/meta/fbnic/fbnic_netdev.c | 2 + drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 25 ++--------- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 2 +- 5 files changed, 63 insertions(+), 22 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic.h +14 -0
@@ -16,6 +16,10 @@#include "fbnic_mac.h" #include "fbnic_rpc.h" +struct fbnic_napi_vector ; + +#define FBNIC_MAX_NAPI_VECTORS 128u +struct fbnic_dev {struct device *dev;struct net_device *netdev;
@@ -29,6 +33,11 @@ struct fbnic_dev {unsigned int pcs_msix_vector;unsigned short num_irqs; +struct { +u8 users; +char name[IFNAMSIZ +9 ]; + } napi_irq[FBNIC_MAX_NAPI_VECTORS ]; +struct delayed_work service_task;struct fbnic_fw_mbx mbx[FBNIC_IPC_MBX_INDICES ];
@@ -148,6 +157,11 @@ void fbnic_hwmon_unregister(struct fbnic_dev *fbd);int fbnic_pcs_irq_enable (struct fbnic_dev *fbd);void fbnic_pcs_irq_disable (struct fbnic_dev *fbd); +void fbnic_napi_name_irqs (struct fbnic_dev *fbd); +int fbnic_napi_request_irq (struct fbnic_dev *fbd, +struct fbnic_napi_vector *nv); +void fbnic_napi_free_irq (struct fbnic_dev *fbd, +struct fbnic_napi_vector *nv);int fbnic_request_irq (struct fbnic_dev *dev,int nr,irq_handler_t handler,unsigned long flags,const char *name,void *data);void fbnic_free_irq (struct fbnic_dev *dev,int nr,void *data);
drivers/net/ethernet/meta/fbnic/fbnic_irq.c +42 -0
48 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +2 -0
@@ -74,6 +74,8 @@ static int fbnic_open(struct net_device *netdev)struct fbnic_net *fbn =netdev_priv (netdev);int err; +fbnic_napi_name_irqs (fbn->fbd); + err =__fbnic_open (fbn);if (!err)fbnic_up (fbn);
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +4 -21
@@ -1036,9 +1036,9 @@ static int fbnic_poll(struct napi_struct *napi, int budget)return 0 ; } -static irqreturn_t fbnic_msix_clean_rings (int __always_unused irq,void *data) +irqreturn_t fbnic_msix_clean_rings (int __always_unused irq,void *data) { -struct fbnic_napi_vector *nv = data; +struct fbnic_napi_vector *nv = *(void **)data;napi_schedule_irqoff (&nv->napi);
@@ -1099,7 +1099,6 @@ static void fbnic_free_napi_vector(struct fbnic_net *fbn, struct fbnic_napi_vector *nv) {struct fbnic_dev *fbd = nv->fbd; -u32 v_idx = nv->v_idx;int i, j;for (i =0 ; i < nv->txt_count; i++) {
@@ -1113,7 +1112,7 @@ static void fbnic_free_napi_vector(struct fbnic_net *fbn,fbnic_remove_rx_ring (fbn, &nv->qt[i].cmpl); } -fbnic_free_irq (fbd, v_idx, nv); +fbnic_napi_free_irq (fbd, nv);page_pool_destroy (nv->page_pool);netif_napi_del (&nv->napi); fbn->napi[fbnic_napi_idx (nv)] =NULL ;
@@ -1129,18 +1128,6 @@ void fbnic_free_napi_vectors(struct fbnic_net *fbn)fbnic_free_napi_vector (fbn, fbn->napi[i]); } -static void fbnic_name_napi_vector (struct fbnic_napi_vector *nv) -{ -unsigned char *dev_name = nv->napi.dev->name; - -if (!nv->rxt_count) -snprintf (nv->name,sizeof (nv->name),"%s-Tx-%u" , dev_name, - nv->v_idx -FBNIC_NON_NAPI_VECTORS ); -else -snprintf (nv->name,sizeof (nv->name),"%s-TxRx-%u" , dev_name, - nv->v_idx -FBNIC_NON_NAPI_VECTORS ); -} -#define FBNIC_PAGE_POOL_FLAGS \ (PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV)
@@ -1240,12 +1227,8 @@ static int fbnic_alloc_napi_vector(struct fbnic_dev *fbd, struct fbnic_net *fbn, goto napi_del; } -/* Initialize vector name */ -fbnic_name_napi_vector (nv); -/* Request the IRQ for napi vector */ - err =fbnic_request_irq (fbd, v_idx, &fbnic_msix_clean_rings, -IRQF_SHARED , nv->name, nv); + err =fbnic_napi_request_irq (fbd, nv);if (err) goto pp_destroy;
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +1 -1
@@ -104,7 +104,6 @@ struct fbnic_napi_vector {struct device *dev;/* Device for DMA unmapping */ struct page_pool *page_pool;struct fbnic_dev *fbd; -char name[IFNAMSIZ +9 ];u16 v_idx;u8 txt_count;
@@ -125,6 +124,7 @@ int fbnic_alloc_napi_vectors(struct fbnic_net *fbn);void fbnic_free_napi_vectors (struct fbnic_net *fbn);int fbnic_alloc_resources (struct fbnic_net *fbn);void fbnic_free_resources (struct fbnic_net *fbn); +irqreturn_t fbnic_msix_clean_rings (int irq,void *data);void fbnic_napi_enable (struct fbnic_net *fbn);void fbnic_napi_disable (struct fbnic_net *fbn);void fbnic_enable (struct fbnic_net *fbn);
Signature · 1 line
2.47.1
Jakub Kicinski
maintainerPATCH 8/10 eth: fbnic: centralize the queue count and NAPI<>queue setting
In reply to Jakub KicinskiFrom: Alexander Duyck <[email protected]>
To simplify dealing with RTNL_ASSERT() requirements further down the line, move setting queue count and NAPI<>queue association to their own helpers.
--- .../net/ethernet/meta/fbnic/fbnic_netdev.c | 9 +- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 92 +++++++++++++------ drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 2 + 3 files changed, 70 insertions(+), 33 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +2 -7
@@ -23,13 +23,7 @@ int __fbnic_open(struct fbnic_net *fbn)if (err) goto free_napi_vectors; - err =netif_set_real_num_tx_queues (fbn->netdev, - fbn->num_tx_queues); -if (err) - goto free_resources; - - err =netif_set_real_num_rx_queues (fbn->netdev, - fbn->num_rx_queues); + err =fbnic_set_netif_queues (fbn);if (err) goto free_resources;
@@ -93,6 +87,7 @@ static int fbnic_stop(struct net_device *netdev)fbnic_time_stop (fbn);fbnic_fw_xmit_ownership_msg (fbn->fbd, false); +fbnic_reset_netif_queues (fbn);fbnic_free_resources (fbn);fbnic_free_napi_vectors (fbn);
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +66 -26
121 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +2 -0
@@ -124,6 +124,8 @@ int fbnic_alloc_napi_vectors(struct fbnic_net *fbn);void fbnic_free_napi_vectors (struct fbnic_net *fbn);int fbnic_alloc_resources (struct fbnic_net *fbn);void fbnic_free_resources (struct fbnic_net *fbn); +int fbnic_set_netif_queues (struct fbnic_net *fbn); +void fbnic_reset_netif_queues (struct fbnic_net *fbn);irqreturn_t fbnic_msix_clean_rings (int irq,void *data);void fbnic_napi_enable (struct fbnic_net *fbn);void fbnic_napi_disable (struct fbnic_net *fbn);
Signature · 1 line
2.47.1
Jakub Kicinski
maintainerPATCH 9/10 eth: fbnic: support ring channel get and set while down
In reply to Jakub KicinskiTrivial implementation of ethtool channel get and set. Set is only supported when device is closed, next patch will add code for live reconfig.
Asymmetric configurations are supported (combined + extra Tx or Rx), so are configurations with independent IRQs for Rx and Tx. Having all 3 NAPI types (combined, Tx, Rx) is not supported.
We used to only call fbnic_reset_indir_tbl() during init. Now that we call it after device had been register must be careful not to override user config.
--- .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 64 +++++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_rpc.c | 3 + 2 files changed, 67 insertions(+)
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +64 -0
@@ -304,6 +304,68 @@ fbnic_set_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh,return 0 ; } +static void fbnic_get_channels (struct net_device *netdev, +struct ethtool_channels *ch) +{ +struct fbnic_net *fbn =netdev_priv (netdev); +struct fbnic_dev *fbd = fbn->fbd; + + ch->max_rx = fbd->max_num_queues; + ch->max_tx = fbd->max_num_queues; + ch->max_combined =min (ch->max_rx, ch->max_tx); + ch->max_other =FBNIC_NON_NAPI_VECTORS ; + +if (fbn->num_rx_queues > fbn->num_napi || + fbn->num_tx_queues > fbn->num_napi) + ch->combined_count =min (fbn->num_rx_queues, + fbn->num_tx_queues); +else + ch->combined_count = + fbn->num_rx_queues + fbn->num_tx_queues - fbn->num_napi; + ch->rx_count = fbn->num_rx_queues - ch->combined_count; + ch->tx_count = fbn->num_tx_queues - ch->combined_count; + ch->other_count =FBNIC_NON_NAPI_VECTORS ; +} + +static void fbnic_set_queues (struct fbnic_net *fbn,struct ethtool_channels *ch, +unsigned int max_napis) +{ + fbn->num_rx_queues = ch->rx_count + ch->combined_count; + fbn->num_tx_queues = ch->tx_count + ch->combined_count; + fbn->num_napi =min (ch->rx_count + ch->tx_count + ch->combined_count, + max_napis); +} + +static int fbnic_set_channels (struct net_device *netdev, +struct ethtool_channels *ch) +{ +struct fbnic_net *fbn =netdev_priv (netdev); +unsigned int max_napis, standalone; +struct fbnic_dev *fbd = fbn->fbd; + + max_napis = fbd->num_irqs -FBNIC_NON_NAPI_VECTORS ; + standalone = ch->rx_count + ch->tx_count; + +/* Limits for standalone queues: +* - each queue has it's own NAPI (num_napi >= rx + tx + combined) +* - combining queues (combined not 0, rx or tx must be 0) +*/ +if ((ch->rx_count && ch->tx_count && ch->combined_count) || + (standalone && standalone + ch->combined_count > max_napis) || + ch->rx_count + ch->combined_count > fbd->max_num_queues || + ch->tx_count + ch->combined_count > fbd->max_num_queues || + ch->other_count !=FBNIC_NON_NAPI_VECTORS ) +return -EINVAL ; + +if (!netif_running (netdev)) { +fbnic_set_queues (fbn, ch, max_napis); +fbnic_reset_indir_tbl (fbn); +return 0 ; + } + +return -EBUSY ; +} +static int fbnic_get_ts_info (struct net_device *netdev,struct kernel_ethtool_ts_info *tsinfo)
@@ -417,6 +479,8 @@ static const struct ethtool_ops fbnic_ethtool_ops = { .get_rxfh_indir_size = fbnic_get_rxfh_indir_size, .get_rxfh = fbnic_get_rxfh, .set_rxfh = fbnic_set_rxfh, + .get_channels = fbnic_get_channels, + .set_channels = fbnic_set_channels, .get_ts_info = fbnic_get_ts_info, .get_ts_stats = fbnic_get_ts_stats, .get_eth_mac_stats = fbnic_get_eth_mac_stats,
drivers/net/ethernet/meta/fbnic/fbnic_rpc.c +3 -0
@@ -13,6 +13,9 @@ void fbnic_reset_indir_tbl(struct fbnic_net *fbn)unsigned int num_rx = fbn->num_rx_queues;unsigned int i; +if (netif_is_rxfh_configured (fbn->netdev)) +return ; +for (i =0 ; i <FBNIC_RPC_RSS_TBL_SIZE ; i++) fbn->indir_tbl[0 ][i] =ethtool_rxfh_indir_default (i, num_rx); }
Signature · 1 line
2.47.1
Jakub Kicinski
maintainerPATCH 10/10 eth: fbnic: support ring channel set while up
In reply to Jakub KicinskiImplement the channel count changes. Copy the netdev priv, allocate new channels using it. Stop, swap, start. Then free the copy of the priv along with the channels it holds, which are now the channels that used to be on the real priv.
--- drivers/net/ethernet/meta/fbnic/fbnic.h | 1 + .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 121 +++++++++++++++++- drivers/net/ethernet/meta/fbnic/fbnic_irq.c | 11 ++ .../net/ethernet/meta/fbnic/fbnic_netdev.h | 1 + drivers/net/ethernet/meta/fbnic/fbnic_pci.c | 2 +- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 8 +- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 5 + 7 files changed, 143 insertions(+), 6 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic.h +1 -0
@@ -162,6 +162,7 @@ int fbnic_napi_request_irq(struct fbnic_dev *fbd, struct fbnic_napi_vector *nv);void fbnic_napi_free_irq (struct fbnic_dev *fbd,struct fbnic_napi_vector *nv); +void fbnic_synchronize_irq (struct fbnic_dev *fbd,int nr);int fbnic_request_irq (struct fbnic_dev *dev,int nr,irq_handler_t handler,unsigned long flags,const char *name,void *data);void fbnic_free_irq (struct fbnic_dev *dev,int nr,void *data);
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +120 -1
139 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_irq.c +11 -0
@@ -146,6 +146,17 @@ void fbnic_pcs_irq_disable(struct fbnic_dev *fbd)free_irq (fbd->pcs_msix_vector, fbd); } +void fbnic_synchronize_irq (struct fbnic_dev *fbd,int nr) +{ +struct pci_dev *pdev =to_pci_dev (fbd->dev); +int irq =pci_irq_vector (pdev, nr); + +if (irq <0 ) +return ; + +synchronize_irq (irq); +} +int fbnic_request_irq (struct fbnic_dev *fbd,int nr,irq_handler_t handler,unsigned long flags,const char *name,void *data) {
drivers/net/ethernet/meta/fbnic/fbnic_netdev.h +1 -0
@@ -65,6 +65,7 @@ struct fbnic_net {int __fbnic_open (struct fbnic_net *fbn);void fbnic_up (struct fbnic_net *fbn);void fbnic_down (struct fbnic_net *fbn); +void fbnic_down_noidle (struct fbnic_net *fbn);struct net_device *fbnic_netdev_alloc (struct fbnic_dev *fbd);void fbnic_netdev_free (struct fbnic_dev *fbd);
drivers/net/ethernet/meta/fbnic/fbnic_pci.c +1 -1
@@ -145,7 +145,7 @@ void fbnic_up(struct fbnic_net *fbn)fbnic_service_task_start (fbn); } -static void fbnic_down_noidle (struct fbnic_net *fbn) +void fbnic_down_noidle (struct fbnic_net *fbn) {fbnic_service_task_stop (fbn);
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +4 -4
@@ -1045,8 +1045,8 @@ irqreturn_t fbnic_msix_clean_rings(int __always_unused irq, void *data)return IRQ_HANDLED ; } -static void fbnic_aggregate_ring_rx_counters (struct fbnic_net *fbn, -struct fbnic_ring *rxr) +void fbnic_aggregate_ring_rx_counters (struct fbnic_net *fbn, +struct fbnic_ring *rxr) {struct fbnic_queue_stats *stats = &rxr->stats;
@@ -1056,8 +1056,8 @@ static void fbnic_aggregate_ring_rx_counters(struct fbnic_net *fbn, fbn->rx_stats.dropped += stats->dropped; } -static void fbnic_aggregate_ring_tx_counters (struct fbnic_net *fbn, -struct fbnic_ring *txr) +void fbnic_aggregate_ring_tx_counters (struct fbnic_net *fbn, +struct fbnic_ring *txr) {struct fbnic_queue_stats *stats = &txr->stats;
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +5 -0
@@ -120,6 +120,11 @@ netdev_features_t fbnic_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t features); +void fbnic_aggregate_ring_rx_counters (struct fbnic_net *fbn, +struct fbnic_ring *rxr); +void fbnic_aggregate_ring_tx_counters (struct fbnic_net *fbn, +struct fbnic_ring *txr); +int fbnic_alloc_napi_vectors (struct fbnic_net *fbn);void fbnic_free_napi_vectors (struct fbnic_net *fbn);int fbnic_alloc_resources (struct fbnic_net *fbn);
Signature · 1 line
2.47.1
Re: [PATCH net-next 10/10] eth: fbnic: support ring channel set while up
drivers/net/ethernet/meta/fbnic/fbnic.h
Quoted 18 lines · Jakub Kicinski
Implement the channel count changes. Copy the netdev priv, allocate new channels using it. Stop, swap, start. Then free the copy of the priv along with the channels it holds, which are now the channels that used to be on the real priv.
Signed-off-by Jakub Kicinski <[email protected]>--- drivers/net/ethernet/meta/fbnic/fbnic.h | 1 + .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 121 +++++++++++++++++- drivers/net/ethernet/meta/fbnic/fbnic_irq.c | 11 ++ .../net/ethernet/meta/fbnic/fbnic_netdev.h | 1 + drivers/net/ethernet/meta/fbnic/fbnic_pci.c | 2 +- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 8 +- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 5 + 7 files changed, 143 insertions(+), 6 deletions(-)drivers/net/ethernet/meta/fbnic/fbnic.h +0
-0
very nice, refreshing and inspirational design
Quoted 36 lines
drivers/net/ethernet/meta/fbnic/fbnic.h +34
-0+static struct fbnic_net *fbnic_clone_create (struct fbnic_net *orig) +{ +struct fbnic_net *clone; + + clone =kmemdup (orig,sizeof (*orig),GFP_KERNEL ); +if (!clone) +return NULL ; + +memset (clone->tx,0 ,sizeof (clone->tx)); +memset (clone->rx,0 ,sizeof (clone->rx)); +memset (clone->napi,0 ,sizeof (clone->napi)); +return clone; +} + +static void fbnic_clone_swap_cfg (struct fbnic_net *orig, +struct fbnic_net *clone) +{ +swap (clone->rcq_size, orig->rcq_size); +swap (clone->hpq_size, orig->hpq_size); +swap (clone->ppq_size, orig->ppq_size); +swap (clone->txq_size, orig->txq_size); +swap (clone->num_rx_queues, orig->num_rx_queues); +swap (clone->num_tx_queues, orig->num_tx_queues); +swap (clone->num_napi, orig->num_napi); +} +static void fbnic_clone_swap (struct fbnic_net *orig, +struct fbnic_net *clone) +{ +struct fbnic_dev *fbd = orig->fbd; +unsigned int i; + +for (i =0 ; i <max (clone->num_napi, orig->num_napi); i++) +fbnic_synchronize_irq (fbd,FBNIC_NON_NAPI_VECTORS + i); +for (i =0 ; i < orig->num_napi; i++)
drivers/net/ethernet/meta/fbnic/fbnic.h
Quoted 10 lines
drivers/net/ethernet/meta/fbnic/fbnic.h +10
-0+fbnic_aggregate_vector_counters (orig, orig->napi[i]); + +fbnic_clone_swap_cfg (orig, clone); + +for (i =0 ; i <ARRAY_SIZE (orig->napi); i++) +swap (clone->napi[i], orig->napi[i]); +for (i =0 ; i <ARRAY_SIZE (orig->tx); i++) +swap (clone->tx[i], orig->tx[i]); +for (i =0 ; i <ARRAY_SIZE (orig->rx); i++) +swap (clone->rx[i], orig->rx[i]);
I would perhaps move the above 6 lines to fbnic_clone_swap_cfg()
Quoted 2 lines
drivers/net/ethernet/meta/fbnic/fbnic.h +2
-0+} +
Jakub Kicinski
maintainerRe: [PATCH net-next 10/10] eth: fbnic: support ring channel set while up
Quoted 10 lines · On Fri, 20 Dec 2024 14:49:02 +0100 Przemek Kitszel wrote:
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c static void fbnic_get_regs(struct net_device *netdev, · line 130
Quoted 8 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +8
-0+fbnic_clone_swap_cfg (orig, clone); + +for (i =0 ; i <ARRAY_SIZE (orig->napi); i++) +swap (clone->napi[i], orig->napi[i]); +for (i =0 ; i <ARRAY_SIZE (orig->tx); i++) +swap (clone->tx[i], orig->tx[i]); +for (i =0 ; i <ARRAY_SIZE (orig->rx); i++) +swap (clone->rx[i], orig->rx[i]);I would perhaps move the above 6 lines to
fbnic_clone_swap_cfg()
Hm, it's here because of how we implemented ringparam changes. They reuse some of the clone stuff but not all. Can we revisit once that's sent?
Re: [PATCH net-next 10/10] eth: fbnic: support ring channel set while up
Quoted 12 lines · Jakub Kicinski
Quoted 10 lines · On Fri, 20 Dec 2024 14:49:02 +0100 Przemek Kitszel wrote:
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c static void fbnic_get_regs(struct net_device *netdev, · line 130
Quoted 8 lines
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +8
-0+fbnic_clone_swap_cfg (orig, clone); + +for (i =0 ; i <ARRAY_SIZE (orig->napi); i++) +swap (clone->napi[i], orig->napi[i]); +for (i =0 ; i <ARRAY_SIZE (orig->tx); i++) +swap (clone->tx[i], orig->tx[i]); +for (i =0 ; i <ARRAY_SIZE (orig->rx); i++) +swap (clone->rx[i], orig->rx[i]);I would perhaps move the above 6 lines to
fbnic_clone_swap_cfg()
Quoted 3 lines
Hm, it's here because of how we implemented ringparam changes. They reuse some of the clone stuff but not all. Can we revisit once that's sent?
This could stay as is here, it's in the fbnic_clone_swap() so does also belong.
The "would+perhaps" + my RB tag meant that I'm fine as-is with this :)
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 15 lines · On Thu, 19 Dec 2024 18:52:31 -0800 you wrote:
Add support for basic RSS config (indirection table, key get and set), and changing the number of channels.
# ./ksft-net-drv/run_kselftest.sh -t drivers/net/hw:rss_ctx.py TAP version 13 1..1 # timeout set to 0 # selftests: drivers/net/hw: rss_ctx.py # KTAP version 1 # 1..15 # ok 1 rss_ctx.test_rss_key_indir # ok 2 rss_ctx.test_rss_queue_reconfigure # ok 3 rss_ctx.test_rss_resize # ok 4 rss_ctx.test_hitless_key_update
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,01/10] eth: fbnic: reorder ethtool code
https://git.kernel.org/netdev/net-next/c/7d0bf493b135 - [net-next,02/10] eth: fbnic: support querying RSS config https://git.kernel.org/netdev/net-next/c/7cb06a6a777c - [net-next,03/10] eth: fbnic: don't reset the secondary RSS indir table https://git.kernel.org/netdev/net-next/c/ef1c28817bf9 - [net-next,04/10] eth: fbnic: support setting RSS configuration https://git.kernel.org/netdev/net-next/c/31ab733e999e - [net-next,05/10] eth: fbnic: let user control the RSS hash fields https://git.kernel.org/netdev/net-next/c/c23a1461bfee - [net-next,06/10] eth: fbnic: store NAPIs in an array instead of the list https://git.kernel.org/netdev/net-next/c/db7159c400ff - [net-next,07/10] eth: fbnic: add IRQ reuse support https://git.kernel.org/netdev/net-next/c/3a856ab34726 - [net-next,08/10] eth: fbnic: centralize the queue count and NAPI<>queue setting https://git.kernel.org/netdev/net-next/c/557d02238e05 - [net-next,09/10] eth: fbnic: support ring channel get and set while down https://git.kernel.org/netdev/net-next/c/3a481cc72673 - [net-next,10/10] eth: fbnic: support ring channel set while up https://git.kernel.org/netdev/net-next/c/52dc722db0d9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html