gve: Add flow steering support
Subsystems (3)
v3 cover gve: Add flow steering support
To support flow steering in GVE driver, there are two adminq changes need to be made in advance.
The first one is adding adminq mutex lock, which is to allow the incoming flow steering operations to be able to temporarily drop the rtnl_lock to reduce the latency for registering flow rules among several NICs at the same time. This could be achieved by the future changes to reduce the drivers' dependencies on the rtnl lock for particular ethtool ops.
The second one is to add the extended adminq command so that we can support larger adminq command such as configure_flow_rule command. In that patch, there is a new added function called gve_adminq_execute_extended_cmd with the attribute of __maybe_unused. That attribute will be removed in the third patch of this series where it will use the previously unused function.
And the other three patches are needed for the actual flow steering feature support in driver.
Jeroen de Borst (4):
gve: Add adminq extended command
gve: Add flow steering device option
gve: Add flow steering adminq commands
gve: Add flow steering ethtool support
Ziwei Xiao (1):
gve: Add adminq mutex lock
drivers/net/ethernet/google/gve/Makefile | 2 +- drivers/net/ethernet/google/gve/gve.h | 54 +++- drivers/net/ethernet/google/gve/gve_adminq.c | 228 +++++++++++++- drivers/net/ethernet/google/gve/gve_adminq.h | 103 ++++++ drivers/net/ethernet/google/gve/gve_ethtool.c | 72 ++++- .../net/ethernet/google/gve/gve_flow_rule.c | 298 ++++++++++++++++++ drivers/net/ethernet/google/gve/gve_main.c | 83 ++++- 7 files changed, 817 insertions(+), 23 deletions(-) create mode 100644 drivers/net/ethernet/google/gve/gve_flow_rule.c
Signature · 1 line
2.45.2.741.gdbec12cfda-goog
PATCH v3 1/5 gve: Add adminq mutex lock
We were depending on the rtnl_lock to make sure there is only one adminq command running at a time. But some commands may take too long to hold the rtnl_lock, such as the upcoming flow steering operations. For such situations, it can temporarily drop the rtnl_lock, and replace it for these operations with a new adminq lock, which can ensure the adminq command execution to be thread-safe.
--- drivers/net/ethernet/google/gve/gve.h | 1 + drivers/net/ethernet/google/gve/gve_adminq.c | 22 +++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-)
drivers/net/ethernet/google/gve/gve.h +1 -0
@@ -724,6 +724,7 @@ struct gve_priv {union gve_adminq_command *adminq;dma_addr_t adminq_bus_addr;struct dma_pool *adminq_pool; +struct mutex adminq_lock;/* Protects adminq command execution */ u32 adminq_mask;/* masks prod_cnt to adminq size */ u32 adminq_prod_cnt;/* free-running count of AQ cmds executed */ u32 adminq_cmd_fail;/* free-running count of AQ cmds failed */
drivers/net/ethernet/google/gve/gve_adminq.c +12 -10
@@ -284,6 +284,7 @@ int gve_adminq_alloc(struct device *dev, struct gve_priv *priv) &priv->reg_bar0->adminq_base_address_lo);iowrite32be (GVE_DRIVER_STATUS_RUN_MASK , &priv->reg_bar0->driver_status); } +mutex_init (&priv->adminq_lock);gve_set_admin_queue_ok (priv);return 0 ; }
@@ -511,28 +512,29 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,return 0 ; } -/* This function is not threadsafe - the caller is responsible for any -* necessary locks. -* The caller is also responsible for making sure there are no commands -* waiting to be executed. -*/ static int gve_adminq_execute_cmd (struct gve_priv *priv,union gve_adminq_command *cmd_orig) {u32 tail, head;int err; +mutex_lock (&priv->adminq_lock); tail =ioread32be (&priv->reg_bar0->adminq_event_counter); head = priv->adminq_prod_cnt; -if (tail != head) -// This is not a valid path -return -EINVAL ; +if (tail != head) { + err = -EINVAL ; + goto out; + } err =gve_adminq_issue_cmd (priv, cmd_orig);if (err) -return err; + goto out; -return gve_adminq_kick_and_wait (priv); + err =gve_adminq_kick_and_wait (priv); + +out: +mutex_unlock (&priv->adminq_lock); +return err; }/* The device specifies that the management vector can either be the first irq
Signature · 1 line
2.45.2.741.gdbec12cfda-goog
PATCH v3 2/5 gve: Add adminq extended command
In reply to Ziwei XiaoFrom: Jeroen de Borst <[email protected]>
The adminq command is limited to 64 bytes per entry and it's 56 bytes for the command itself at maximum. To support larger commands, we need to dma_alloc a separate memory to put the command in that memory and send the dma memory address instead of the actual command.
Introduce an extended adminq command to wrap the real command with the inner opcode and the allocated dma memory address specified. Once the device receives it, it can get the real command from the given dma memory address. As designed with the device, all the extended commands will use inner opcode larger than 0xFF.
---
Changes in v2:
- Update the commit message to use imperative mood
- Add the __maybe_unused attribute for the unused function of gve_adminq_execute_extended_cmd
drivers/net/ethernet/google/gve/gve_adminq.c | 31 ++++++++++++++++++++ drivers/net/ethernet/google/gve/gve_adminq.h | 12 ++++++++ 2 files changed, 43 insertions(+)
drivers/net/ethernet/google/gve/gve_adminq.c +31 -0
@@ -461,6 +461,8 @@ static int gve_adminq_issue_cmd(struct gve_priv *priv,memcpy (cmd, cmd_orig,sizeof (*cmd_orig)); opcode =be32_to_cpu (READ_ONCE (cmd->opcode)); +if (opcode ==GVE_ADMINQ_EXTENDED_COMMAND ) + opcode =be32_to_cpu (cmd->extended_command.inner_opcode);switch (opcode) {case GVE_ADMINQ_DESCRIBE_DEVICE :
@@ -537,6 +539,35 @@ static int gve_adminq_execute_cmd(struct gve_priv *priv,return err; } +static int __maybe_unused gve_adminq_execute_extended_cmd (struct gve_priv *priv,u32 opcode, +size_t cmd_size,void *cmd_orig) +{ +union gve_adminq_command cmd; +dma_addr_t inner_cmd_bus; +void *inner_cmd; +int err; + + inner_cmd =dma_alloc_coherent (&priv->pdev->dev, cmd_size, + &inner_cmd_bus,GFP_KERNEL ); +if (!inner_cmd) +return -ENOMEM ; + +memcpy (inner_cmd, cmd_orig, cmd_size); + +memset (&cmd,0 ,sizeof (cmd)); + cmd.opcode =cpu_to_be32 (GVE_ADMINQ_EXTENDED_COMMAND ); + cmd.extended_command = (struct gve_adminq_extended_command ) { + .inner_opcode =cpu_to_be32 (opcode), + .inner_length =cpu_to_be32 (cmd_size), + .inner_command_addr =cpu_to_be64 (inner_cmd_bus), + }; + + err =gve_adminq_execute_cmd (priv, &cmd); + +dma_free_coherent (&priv->pdev->dev, cmd_size, inner_cmd, inner_cmd_bus); +return err; +} +/* The device specifies that the management vector can either be the first irq * or the last irq. ntfy_blk_msix_base_idx indicates the first irq assigned to * the ntfy blks. It if is 0 then the management vector is last, if it is 1 then
drivers/net/ethernet/google/gve/gve_adminq.h +12 -0
@@ -25,6 +25,9 @@ enum gve_adminq_opcodes {GVE_ADMINQ_REPORT_LINK_SPEED =0xD ,GVE_ADMINQ_GET_PTYPE_MAP =0xE ,GVE_ADMINQ_VERIFY_DRIVER_COMPATIBILITY =0xF , + +/* For commands that are larger than 56 bytes */ + GVE_ADMINQ_EXTENDED_COMMAND = 0xFF, };/* Admin queue status codes */
@@ -208,6 +211,14 @@ enum gve_driver_capbility {#define GVE_DRIVER_CAPABILITY_FLAGS3 0x0#define GVE_DRIVER_CAPABILITY_FLAGS4 0x0 +struct gve_adminq_extended_command { +__be32 inner_opcode; +__be32 inner_length; +__be64 inner_command_addr; +}; + +static_assert (sizeof (struct gve_adminq_extended_command ) ==16 ); +struct gve_driver_info {u8 os_type;/* 0x01 = Linux */ u8 driver_major;
@@ -432,6 +443,7 @@ union gve_adminq_command {struct gve_adminq_get_ptype_map get_ptype_map;struct gve_adminq_verify_driver_compatibility verify_driver_compatibility; +struct gve_adminq_extended_command extended_command; }; };u8 reserved[64 ];
Signature · 1 line
2.45.2.741.gdbec12cfda-goog
PATCH v3 3/5 gve: Add flow steering device option
In reply to Ziwei XiaoFrom: Jeroen de Borst <[email protected]>
Add a new device option to signal to the driver that the device supports flow steering. This device option also carries the maximum number of flow steering rules that the device can store.
---
Changes in v3:
- Move the priv->dev->hw_features |= NETIF_F_NTUPLE; to where flow steering is supported when receiving the valid flow steering device option(Jakub Kicinski)
drivers/net/ethernet/google/gve/gve.h | 2 + drivers/net/ethernet/google/gve/gve_adminq.c | 40 +++++++++++++++++++- drivers/net/ethernet/google/gve/gve_adminq.h | 11 ++++++ 3 files changed, 51 insertions(+), 2 deletions(-)
drivers/net/ethernet/google/gve/gve.h +2 -0
@@ -786,6 +786,8 @@ struct gve_priv {u16 header_buf_size;/* device configured, header-split supported if non-zero */ bool header_split_enabled;/* True if the header split is enabled by the user */ + +u32 max_flow_rules; };enum gve_service_task_flags_bit {
drivers/net/ethernet/google/gve/gve_adminq.c +38 -2
@@ -44,6 +44,7 @@ void gve_parse_device_option(struct gve_priv *priv,struct gve_device_option_jumbo_frames **dev_op_jumbo_frames, struct gve_device_option_dqo_qpl **dev_op_dqo_qpl, struct gve_device_option_buffer_sizes **dev_op_buffer_sizes, + struct gve_device_option_flow_steering **dev_op_flow_steering, struct gve_device_option_modify_ring **dev_op_modify_ring) { u32 req_feat_mask = be32_to_cpu(option->required_features_mask);
@@ -189,6 +190,23 @@ void gve_parse_device_option(struct gve_priv *priv,if (option_length ==GVE_DEVICE_OPTION_NO_MIN_RING_SIZE ) priv->default_min_ring_size = true;break ; +case GVE_DEV_OPT_ID_FLOW_STEERING : +if (option_length <sizeof (**dev_op_flow_steering) || + req_feat_mask !=GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING ) { +dev_warn (&priv->pdev->dev,GVE_DEVICE_OPTION_ERROR_FMT , +"Flow Steering" , + (int )sizeof (**dev_op_flow_steering), +GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING , + option_length, req_feat_mask); +break ; + } + +if (option_length >sizeof (**dev_op_flow_steering)) +dev_warn (&priv->pdev->dev, +GVE_DEVICE_OPTION_TOO_BIG_FMT , +"Flow Steering" ); + *dev_op_flow_steering = (void *)(option +1 ); +break ;default :/* If we don't recognize the option just continue * without doing anything.
@@ -208,6 +226,7 @@ gve_process_device_options(struct gve_priv *priv,struct gve_device_option_jumbo_frames **dev_op_jumbo_frames, struct gve_device_option_dqo_qpl **dev_op_dqo_qpl, struct gve_device_option_buffer_sizes **dev_op_buffer_sizes, + struct gve_device_option_flow_steering **dev_op_flow_steering, struct gve_device_option_modify_ring **dev_op_modify_ring) { const int num_options = be16_to_cpu(descriptor->num_device_options);
@@ -230,7 +249,7 @@ gve_process_device_options(struct gve_priv *priv, dev_op_gqi_rda, dev_op_gqi_qpl, dev_op_dqo_rda, dev_op_jumbo_frames, dev_op_dqo_qpl, dev_op_buffer_sizes, - dev_op_modify_ring); + dev_op_flow_steering, dev_op_modify_ring); dev_opt = next_opt; }
@@ -838,6 +857,8 @@ static void gve_enable_supported_features(struct gve_priv *priv, *dev_op_dqo_qpl, const struct gve_device_option_buffer_sizes *dev_op_buffer_sizes, + const struct gve_device_option_flow_steering + *dev_op_flow_steering, const struct gve_device_option_modify_ring *dev_op_modify_ring) {
@@ -890,10 +911,23 @@ static void gve_enable_supported_features(struct gve_priv *priv, priv->min_tx_desc_cnt =be16_to_cpu (dev_op_modify_ring->min_tx_ring_size); } } + +if (dev_op_flow_steering && + (supported_features_mask &GVE_SUP_FLOW_STEERING_MASK )) { +if (dev_op_flow_steering->max_flow_rules) { + priv->max_flow_rules = +be32_to_cpu (dev_op_flow_steering->max_flow_rules); + priv->dev->hw_features |=NETIF_F_NTUPLE ; +dev_info (&priv->pdev->dev, +"FLOW STEERING device option enabled with max rule limit of %u.\n" , + priv->max_flow_rules); + } + } }int gve_adminq_describe_device (struct gve_priv *priv) { +struct gve_device_option_flow_steering *dev_op_flow_steering =NULL ;struct gve_device_option_buffer_sizes *dev_op_buffer_sizes =NULL ;struct gve_device_option_jumbo_frames *dev_op_jumbo_frames =NULL ;struct gve_device_option_modify_ring *dev_op_modify_ring =NULL ;
@@ -930,6 +964,7 @@ int gve_adminq_describe_device(struct gve_priv *priv) &dev_op_gqi_qpl, &dev_op_dqo_rda, &dev_op_jumbo_frames, &dev_op_dqo_qpl, &dev_op_buffer_sizes, + &dev_op_flow_steering, &dev_op_modify_ring);if (err) goto free_device_descriptor;
@@ -991,7 +1026,8 @@ int gve_adminq_describe_device(struct gve_priv *priv)gve_enable_supported_features (priv, supported_features_mask, dev_op_jumbo_frames, dev_op_dqo_qpl, - dev_op_buffer_sizes, dev_op_modify_ring); + dev_op_buffer_sizes, dev_op_flow_steering, + dev_op_modify_ring); free_device_descriptor:dma_pool_free (priv->adminq_pool, descriptor, descriptor_bus);
drivers/net/ethernet/google/gve/gve_adminq.h +11 -0
@@ -146,6 +146,14 @@ struct gve_device_option_modify_ring {static_assert (sizeof (struct gve_device_option_modify_ring ) ==12 ); +struct gve_device_option_flow_steering { +__be32 supported_features_mask; +__be32 reserved; +__be32 max_flow_rules; +}; + +static_assert (sizeof (struct gve_device_option_flow_steering ) ==12 ); +/* Terminology: * * RDA - Raw DMA Addressing - Buffers associated with SKBs are directly DMA
@@ -163,6 +171,7 @@ enum gve_dev_opt_id {GVE_DEV_OPT_ID_DQO_QPL =0x7 ,GVE_DEV_OPT_ID_JUMBO_FRAMES =0x8 ,GVE_DEV_OPT_ID_BUFFER_SIZES =0xa , + GVE_DEV_OPT_ID_FLOW_STEERING = 0xb, }; enum gve_dev_opt_req_feat_mask {
@@ -174,12 +183,14 @@ enum gve_dev_opt_req_feat_mask {GVE_DEV_OPT_REQ_FEAT_MASK_DQO_QPL =0x0 ,GVE_DEV_OPT_REQ_FEAT_MASK_BUFFER_SIZES =0x0 ,GVE_DEV_OPT_REQ_FEAT_MASK_MODIFY_RING =0x0 , + GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING = 0x0, };enum gve_sup_feature_mask {GVE_SUP_MODIFY_RING_MASK =1 <<0 ,GVE_SUP_JUMBO_FRAMES_MASK =1 <<2 ,GVE_SUP_BUFFER_SIZES_MASK =1 <<4 , +GVE_SUP_FLOW_STEERING_MASK =1 <<5 , };#define GVE_DEV_OPT_LEN_GQI_RAW_ADDRESSING 0x0
Signature · 1 line
2.45.2.741.gdbec12cfda-goog
PATCH v3 4/5 gve: Add flow steering adminq commands
In reply to Ziwei XiaoFrom: Jeroen de Borst <[email protected]>
Add new adminq commands for the driver to configure and query flow rules that are stored in the device. Flow steering rules are assigned with a location that determines the relative order of the rules.
Flow rules can run up to an order of millions. In such cases, storing a full copy of the rules in the driver to prepare for the ethtool query is infeasible while querying them from the device is better. That needs to be optimized too so that we don't send a lot of adminq commands. The solution here is to store a limited number of rules/rule ids in the driver in a cache. Use dma_pool to allocate 4k bytes which lets device write at most 46 flow rules(4096/88) or 1024 rule ids(4096/4) at a time.
For configuring flow rules, there are 3 sub-commands:
- ADD which adds a rule at the location supplied
- DEL which deletes the rule at the location supplied
- RESET which clears all currently active rules in the device
For querying flow rules, there are also 3 sub-commands:
- QUERY_RULES corresponds to ETHTOOL_GRXCLSRULE. It fills the rules in the allocated cache after querying the device
- QUERY_RULES_IDS corresponds to ETHTOOL_GRXCLSRLALL. It fills the rule_ids in the allocated cache after querying the device
- QUERY_RULES_STATS corresponds to ETHTOOL_GRXCLSRLCNT. It queries the device's current flow rule number and the supported max flow rule limit
---
Changes in v2:
- Update the commit message to use imperative mood
- Remove the variable comments of num_flow_rules and struct gve_query_flow_rules_descriptor since their names are already self-describing
- Remove the __maybe_unused attribute for gve_adminq_execute_extended_cmd since it's no longer unused from this patch
- Add a new struct gve_adminq_queried_flow_rule to store the queried rule from the device instead of using gve_flow_rule
- Remove the unused variable of descriptor_end
- Remove the check for whether the total length is smaller than the allocated memory length. Instead, add the check for whether the queried results length match with the expected length
- Update the variable names of the struct gve_adminq_flow_rule_cfg_opcode to be more self-descriptive
drivers/net/ethernet/google/gve/gve.h | 43 ++++++ drivers/net/ethernet/google/gve/gve_adminq.c | 139 +++++++++++++++++- drivers/net/ethernet/google/gve/gve_adminq.h | 80 ++++++++++ drivers/net/ethernet/google/gve/gve_ethtool.c | 5 +- drivers/net/ethernet/google/gve/gve_main.c | 51 ++++++- 5 files changed, 314 insertions(+), 4 deletions(-)
drivers/net/ethernet/google/gve/gve.h +43 -0
@@ -60,6 +60,11 @@#define GVE_DEFAULT_RX_BUFFER_OFFSET 2048 +#define GVE_FLOW_RULES_CACHE_SIZE \ + (GVE_ADMINQ_BUFFER_SIZE / sizeof(struct gve_adminq_queried_flow_rule)) +#define GVE_FLOW_RULE_IDS_CACHE_SIZE \ + (GVE_ADMINQ_BUFFER_SIZE / sizeof(((struct gve_adminq_queried_flow_rule *)0)->location)) +#define GVE_XDP_ACTIONS 5#define GVE_GQ_TX_MIN_PKT_DESC_BYTES 182
@@ -678,6 +683,39 @@ enum gve_queue_format { GVE_DQO_QPL_FORMAT = 0x4, }; +struct gve_flow_spec { +__be32 src_ip[4 ]; +__be32 dst_ip[4 ]; +union { +struct { +__be16 src_port; +__be16 dst_port; + }; +__be32 spi; + }; +union { +u8 tos; +u8 tclass; + }; +}; + +struct gve_flow_rule { +u32 location; +u16 flow_type; +u16 action; +struct gve_flow_spec key; +struct gve_flow_spec mask; +}; + +struct gve_flow_rules_cache { +bool rules_cache_synced;/* False if the driver's rules_cache is outdated */ +struct gve_adminq_queried_flow_rule *rules_cache; +__be32 *rule_ids_cache; +/* The total number of queried rules that stored in the caches */ +u32 rules_cache_num; +u32 rule_ids_cache_num; +}; +struct gve_priv {struct net_device *dev;struct gve_tx_ring *tx;/* array of tx_cfg.num_queues */
@@ -744,6 +782,8 @@ struct gve_priv {u32 adminq_report_link_speed_cnt;u32 adminq_get_ptype_map_cnt;u32 adminq_verify_driver_compatibility_cnt; +u32 adminq_query_flow_rules_cnt; +u32 adminq_cfg_flow_rule_cnt;/* Global stats */ u32 interface_up_cnt;/* count of times interface turned up since last reset */
@@ -788,6 +828,9 @@ struct gve_priv {bool header_split_enabled;/* True if the header split is enabled by the user */ u32 max_flow_rules; +u32 num_flow_rules; + +struct gve_flow_rules_cache flow_rules_cache; };enum gve_service_task_flags_bit {
drivers/net/ethernet/google/gve/gve_adminq.c +137 -2
160 lines not on this page · raw message
drivers/net/ethernet/google/gve/gve_adminq.h +80 -0
109 lines not on this page · raw message
drivers/net/ethernet/google/gve/gve_ethtool.c +4 -1
@@ -74,7 +74,8 @@ static const char gve_gstrings_adminq_stats[][ETH_GSTRING_LEN] = {"adminq_create_tx_queue_cnt" ,"adminq_create_rx_queue_cnt" ,"adminq_destroy_tx_queue_cnt" ,"adminq_destroy_rx_queue_cnt" ,"adminq_dcfg_device_resources_cnt" ,"adminq_set_driver_parameter_cnt" , -"adminq_report_stats_cnt" ,"adminq_report_link_speed_cnt" ,"adminq_get_ptype_map_cnt" +"adminq_report_stats_cnt" ,"adminq_report_link_speed_cnt" ,"adminq_get_ptype_map_cnt" , + "adminq_query_flow_rules", "adminq_cfg_flow_rule", }; static const char gve_gstrings_priv_flags[][ETH_GSTRING_LEN] = {
@@ -450,6 +451,8 @@ gve_get_ethtool_stats(struct net_device *netdev, data[i++] = priv->adminq_report_stats_cnt; data[i++] = priv->adminq_report_link_speed_cnt; data[i++] = priv->adminq_get_ptype_map_cnt; + data[i++] = priv->adminq_query_flow_rules_cnt; + data[i++] = priv->adminq_cfg_flow_rule_cnt; } static void gve_get_channels(struct net_device *netdev,
drivers/net/ethernet/google/gve/gve_main.c +50 -1
77 lines not on this page · raw message
Signature · 1 line
2.45.2.741.gdbec12cfda-goog
PATCH v3 5/5 gve: Add flow steering ethtool support
In reply to Ziwei XiaoFrom: Jeroen de Borst <[email protected]>
Implement the ethtool commands that can be used to configure and query flow-steering rules.
A large part of this change consists of translating the ethtool representation of 'ntuples' to our internal gve_flow_rule and vice-versa in the new created gve_flow_rule.c
Considering the possible large amount of flow rules, the driver doesn't store all the rules locally. When the user runs 'ethtool -n <nic>' to check the registered rules, the driver will send adminq command to query a limited amount of rules/rule ids(that filled in a 4096 bytes dma memory) at a time as a cache for the ethtool queries. The adminq query commands will be repeated for several times until the ethtool has queried all the needed rules.
---
Changes in v3:
- Remove the codes which drop the rtnl lock for flow steering ethtool commands, and also remove the related commit message.
Because the dropping rtnl lock part is used for improve the efficiency of adding rules for multiple nics at the same time, keeping the rtnl lock itself doesn't impact the functionality of flow steering feature. Also, since there is ongoing work for reducing the dependency of the rtnl lock for the dev_ethtool
(https://lore.kernel.org/netdev/[email protected]/),
it can add an ethtool ops to declare the intention of dropping the rtnl lock for flow steering ethtool operations once that change is ready in the future.
Changes in v2:
- Fix the sparse warning of be16_to_cpu by switching to use the new added structure gve_adminq_queried_flow_rule from the previous patch to do the be16_to_cpu operations
- Use kvfree instead of kfree for the rule allocated by kvzalloc
- Delete the check that disallows rx queue count changing when there are rules alive because it already has a check in net/ethtool/channels.c that ensures rx queue count change to be failed if requested channel counts are too low for existing ntuple filter settings
drivers/net/ethernet/google/gve/Makefile | 2 +- drivers/net/ethernet/google/gve/gve.h | 8 +- drivers/net/ethernet/google/gve/gve_ethtool.c | 67 +++- .../net/ethernet/google/gve/gve_flow_rule.c | 298 ++++++++++++++++++ drivers/net/ethernet/google/gve/gve_main.c | 32 +- 5 files changed, 398 insertions(+), 9 deletions(-) create mode 100644 drivers/net/ethernet/google/gve/gve_flow_rule.c
drivers/net/ethernet/google/gve/Makefile +1 -1
@@ -1,4 +1,4 @@ # Makefile for the Google virtual Ethernet (gve) driver obj-$(CONFIG_GVE) += gve.o -gve-objs := gve_main.o gve_tx.o gve_tx_dqo.o gve_rx.o gve_rx_dqo.o gve_ethtool.o gve_adminq.o gve_utils.o +gve-objs := gve_main.o gve_tx.o gve_tx_dqo.o gve_rx.o gve_rx_dqo.o gve_ethtool.o gve_adminq.o gve_utils.o gve_flow_rule.o
drivers/net/ethernet/google/gve/gve.h +7 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: (GPL-2.0 OR MIT) * Google virtual Ethernet (gve) driver * -* Copyright (C) 2015-2021 Google, Inc. +* Copyright (C) 2015-2024 Google LLC */ #ifndef _GVE_H_
@@ -1170,6 +1170,12 @@ int gve_adjust_config(struct gve_priv *priv,int gve_adjust_queues (struct gve_priv *priv,struct gve_queue_config new_rx_config,struct gve_queue_config new_tx_config); +/* flow steering rule */ +int gve_get_flow_rule_entry (struct gve_priv *priv,struct ethtool_rxnfc *cmd); +int gve_get_flow_rule_ids (struct gve_priv *priv,struct ethtool_rxnfc *cmd,u32 *rule_locs); +int gve_add_flow_rule (struct gve_priv *priv,struct ethtool_rxnfc *cmd); +int gve_del_flow_rule (struct gve_priv *priv,struct ethtool_rxnfc *cmd); +int gve_flow_rules_reset (struct gve_priv *priv);/* report stats handling */ void gve_handle_report_stats (struct gve_priv *priv);/* exported by ethtool.c */
drivers/net/ethernet/google/gve/gve_ethtool.c +66 -1
85 lines not on this page · raw message
drivers/net/ethernet/google/gve/gve_flow_rule.c new file +298 -0
298 lines not on this page · raw message
drivers/net/ethernet/google/gve/gve_main.c +26 -6
@@ -1,7 +1,7 @@// SPDX-License-Identifier: (GPL-2.0 OR MIT) /* Google virtual Ethernet (gve) driver * -* Copyright (C) 2015-2021 Google, Inc. +* Copyright (C) 2015-2024 Google LLC */ #include <linux/bpf.h>
@@ -635,6 +635,12 @@ static void gve_teardown_device_resources(struct gve_priv *priv)/* Tell device its resources are being freed */ if (gve_get_device_resources_ok (priv)) { + err =gve_flow_rules_reset (priv); +if (err) { +dev_err (&priv->pdev->dev, +"Failed to reset flow rules: err=%d\n" , err); +gve_trigger_reset (priv); + }/* detach the stats report */ err =gve_adminq_report_stats (priv,0 ,0x0 ,GVE_STATS_REPORT_TIMER_PERIOD );if (err) {
@@ -1779,6 +1785,14 @@ static int gve_xdp(struct net_device *dev, struct netdev_bpf *xdp) } } +int gve_flow_rules_reset (struct gve_priv *priv) +{ +if (!priv->max_flow_rules) +return 0 ; + +return gve_adminq_reset_flow_rules (priv); +} +int gve_adjust_config (struct gve_priv *priv,struct gve_tx_alloc_rings_cfg *tx_alloc_cfg,struct gve_rx_alloc_rings_cfg *rx_alloc_cfg)
@@ -2052,15 +2066,21 @@ static int gve_set_features(struct net_device *netdev, netdev->features ^=NETIF_F_LRO ;if (netif_carrier_ok (netdev)) { err =gve_adjust_config (priv, &tx_alloc_cfg, &rx_alloc_cfg); -if (err) { -/* Revert the change on error. */ - netdev->features = orig_features; -return err; - } +if (err) + goto revert_features; } } +if ((netdev->features &NETIF_F_NTUPLE ) && !(features &NETIF_F_NTUPLE )) { + err =gve_flow_rules_reset (priv); +if (err) + goto revert_features; + }return 0 ; + +revert_features: + netdev->features = orig_features; +return err; }static const struct net_device_ops gve_netdev_ops = {
Signature · 1 line
2.45.2.741.gdbec12cfda-goog
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 11 lines · On Tue, 25 Jun 2024 00:12:26 +0000 you wrote:
To support flow steering in GVE driver, there are two adminq changes need to be made in advance.
The first one is adding adminq mutex lock, which is to allow the incoming flow steering operations to be able to temporarily drop the
rtnl_lockto reduce the latency for registering flow rules among several NICs at the same time. This could be achieved by the future changes to reduce the drivers' dependencies on the rtnl lock for particular ethtool ops.[...]
Here is the summary with links:
- [net-next,v3,1/5] gve: Add adminq mutex lock
https://git.kernel.org/netdev/net-next/c/1108566ca509 - [net-next,v3,2/5] gve: Add adminq extended command https://git.kernel.org/netdev/net-next/c/fcfe6318dbac - [net-next,v3,3/5] gve: Add flow steering device option https://git.kernel.org/netdev/net-next/c/3519c00557e0 - [net-next,v3,4/5] gve: Add flow steering adminq commands https://git.kernel.org/netdev/net-next/c/57718b60df9b - [net-next,v3,5/5] gve: Add flow steering ethtool support https://git.kernel.org/netdev/net-next/c/6f3bc487565d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html