mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 11:03:07 -04:00
Merge branch 'gve-adminq-mode-related-refactors'
Harshitha Ramamurthy says: ==================== gve: AdminQ mode related refactors [part] ==================== Link: https://patch.msgid.link/20260814021406.3044324-1-hramamurthy@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -385,7 +385,7 @@ void gve_adminq_release(struct gve_priv *priv)
|
||||
gve_clear_admin_queue_ok(priv);
|
||||
}
|
||||
|
||||
void gve_adminq_free(struct device *dev, struct gve_priv *priv)
|
||||
void gve_adminq_free(struct gve_priv *priv)
|
||||
{
|
||||
if (!gve_get_admin_queue_ok(priv))
|
||||
return;
|
||||
@@ -920,19 +920,6 @@ int gve_adminq_destroy_rx_queues(struct gve_priv *priv, u32 num_queues)
|
||||
return err;
|
||||
}
|
||||
|
||||
static void gve_set_default_desc_cnt(struct gve_priv *priv,
|
||||
const struct gve_device_descriptor *descriptor)
|
||||
{
|
||||
priv->tx_desc_cnt = be16_to_cpu(descriptor->tx_queue_entries);
|
||||
priv->rx_desc_cnt = be16_to_cpu(descriptor->rx_queue_entries);
|
||||
|
||||
/* set default ranges */
|
||||
priv->max_tx_desc_cnt = priv->tx_desc_cnt;
|
||||
priv->max_rx_desc_cnt = priv->rx_desc_cnt;
|
||||
priv->min_tx_desc_cnt = priv->tx_desc_cnt;
|
||||
priv->min_rx_desc_cnt = priv->rx_desc_cnt;
|
||||
}
|
||||
|
||||
static void gve_set_default_rss_sizes(struct gve_priv *priv)
|
||||
{
|
||||
if (!gve_is_gqi(priv)) {
|
||||
@@ -1049,8 +1036,6 @@ int gve_adminq_describe_device(struct gve_priv *priv)
|
||||
union gve_adminq_command cmd;
|
||||
dma_addr_t descriptor_bus;
|
||||
int err = 0;
|
||||
u8 *mac;
|
||||
u16 mtu;
|
||||
|
||||
memset(&cmd, 0, sizeof(cmd));
|
||||
descriptor = dma_pool_alloc(priv->adminq_pool, GFP_KERNEL,
|
||||
@@ -1112,34 +1097,17 @@ int gve_adminq_describe_device(struct gve_priv *priv)
|
||||
"Driver is running with GQI QPL queue format.\n");
|
||||
}
|
||||
|
||||
/* set default descriptor counts */
|
||||
gve_set_default_desc_cnt(priv, descriptor);
|
||||
|
||||
gve_set_default_rss_sizes(priv);
|
||||
|
||||
/* DQO supports HW-GRO and UDP_GSO */
|
||||
if (gve_is_dqo(priv)) {
|
||||
u64 additional_features = NETIF_F_GRO_HW | NETIF_F_GSO_UDP_L4;
|
||||
|
||||
priv->dev->hw_features |= additional_features;
|
||||
priv->dev->features |= additional_features;
|
||||
}
|
||||
|
||||
priv->max_registered_pages =
|
||||
be64_to_cpu(descriptor->max_registered_pages);
|
||||
mtu = be16_to_cpu(descriptor->mtu);
|
||||
if (mtu < ETH_MIN_MTU) {
|
||||
dev_err(&priv->pdev->dev, "MTU %d below minimum MTU\n", mtu);
|
||||
err = -EINVAL;
|
||||
err = gve_set_mtu(priv, descriptor);
|
||||
if (err)
|
||||
goto free_device_descriptor;
|
||||
}
|
||||
priv->dev->max_mtu = mtu;
|
||||
|
||||
priv->num_event_counters = be16_to_cpu(descriptor->counters);
|
||||
eth_hw_addr_set(priv->dev, descriptor->mac);
|
||||
mac = descriptor->mac;
|
||||
dev_info(&priv->pdev->dev, "MAC addr: %pM\n", mac);
|
||||
priv->tx_pages_per_qpl = be16_to_cpu(descriptor->tx_pages_per_qpl);
|
||||
priv->default_num_queues = be16_to_cpu(descriptor->default_num_queues);
|
||||
|
||||
gve_set_mac(priv, descriptor);
|
||||
|
||||
gve_set_queue_properties(priv, descriptor);
|
||||
|
||||
gve_enable_supported_features(priv, supported_features_mask,
|
||||
dev_op_jumbo_frames, dev_op_dqo_qpl,
|
||||
@@ -1600,3 +1568,44 @@ int gve_adminq_query_rss_config(struct gve_priv *priv, struct ethtool_rxfh_param
|
||||
dma_pool_free(priv->adminq_pool, descriptor, descriptor_bus);
|
||||
return err;
|
||||
}
|
||||
|
||||
int gve_set_num_ntfy_blks(struct gve_priv *priv)
|
||||
{
|
||||
int num_ntfy;
|
||||
|
||||
num_ntfy = pci_msix_vec_count(priv->pdev);
|
||||
if (num_ntfy <= 0) {
|
||||
dev_err(&priv->pdev->dev,
|
||||
"could not count MSI-x vectors: err=%d\n", num_ntfy);
|
||||
return num_ntfy;
|
||||
} else if (num_ntfy < GVE_MIN_MSIX) {
|
||||
dev_err(&priv->pdev->dev, "gve needs at least %d MSI-x vectors, but only has %d\n",
|
||||
GVE_MIN_MSIX, num_ntfy);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* gvnic has one Notification Block per MSI-x vector, except for the
|
||||
* management vector
|
||||
*/
|
||||
priv->num_ntfy_blks = (num_ntfy - 1) & ~0x1;
|
||||
priv->mgmt_msix_idx = priv->num_ntfy_blks;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gve_set_num_queues(struct gve_priv *priv)
|
||||
{
|
||||
priv->tx_cfg.max_queues =
|
||||
min_t(int, priv->tx_cfg.max_queues, priv->num_ntfy_blks / 2);
|
||||
priv->rx_cfg.max_queues =
|
||||
min_t(int, priv->rx_cfg.max_queues, priv->num_ntfy_blks / 2);
|
||||
|
||||
priv->tx_cfg.num_queues = priv->tx_cfg.max_queues;
|
||||
priv->rx_cfg.num_queues = priv->rx_cfg.max_queues;
|
||||
if (priv->default_num_queues > 0) {
|
||||
priv->tx_cfg.num_queues = min_t(int, priv->default_num_queues,
|
||||
priv->tx_cfg.num_queues);
|
||||
priv->rx_cfg.num_queues = min_t(int, priv->default_num_queues,
|
||||
priv->rx_cfg.num_queues);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,7 +620,7 @@ union gve_adminq_command {
|
||||
static_assert(sizeof(union gve_adminq_command) == 64);
|
||||
|
||||
int gve_adminq_alloc(struct device *dev, struct gve_priv *priv);
|
||||
void gve_adminq_free(struct device *dev, struct gve_priv *priv);
|
||||
void gve_adminq_free(struct gve_priv *priv);
|
||||
void gve_adminq_release(struct gve_priv *priv);
|
||||
int gve_adminq_describe_device(struct gve_priv *priv);
|
||||
int gve_adminq_configure_device_resources(struct gve_priv *priv,
|
||||
@@ -656,5 +656,12 @@ int gve_adminq_report_nic_ts(struct gve_priv *priv,
|
||||
struct gve_ptype_lut;
|
||||
int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv,
|
||||
struct gve_ptype_lut *ptype_lut);
|
||||
|
||||
int gve_set_num_ntfy_blks(struct gve_priv *priv);
|
||||
void gve_set_num_queues(struct gve_priv *priv);
|
||||
void gve_set_queue_properties(struct gve_priv *priv,
|
||||
struct gve_device_descriptor *descriptor);
|
||||
int gve_set_mtu(struct gve_priv *priv,
|
||||
struct gve_device_descriptor *descriptor);
|
||||
void gve_set_mac(struct gve_priv *priv,
|
||||
struct gve_device_descriptor *descriptor);
|
||||
#endif /* _GVE_ADMINQ_H */
|
||||
|
||||
@@ -2398,9 +2398,57 @@ static const struct xdp_metadata_ops gve_xdp_metadata_ops = {
|
||||
.xmo_rx_timestamp = gve_xdp_rx_timestamp,
|
||||
};
|
||||
|
||||
static void gve_set_default_desc_cnt(struct gve_priv *priv,
|
||||
const struct gve_device_descriptor *descriptor)
|
||||
{
|
||||
priv->tx_desc_cnt = be16_to_cpu(descriptor->tx_queue_entries);
|
||||
priv->rx_desc_cnt = be16_to_cpu(descriptor->rx_queue_entries);
|
||||
|
||||
/* set default ranges */
|
||||
priv->max_tx_desc_cnt = priv->tx_desc_cnt;
|
||||
priv->max_rx_desc_cnt = priv->rx_desc_cnt;
|
||||
priv->min_tx_desc_cnt = priv->tx_desc_cnt;
|
||||
priv->min_rx_desc_cnt = priv->rx_desc_cnt;
|
||||
}
|
||||
|
||||
void gve_set_queue_properties(struct gve_priv *priv,
|
||||
struct gve_device_descriptor *descriptor)
|
||||
{
|
||||
/* set default descriptor counts */
|
||||
gve_set_default_desc_cnt(priv, descriptor);
|
||||
|
||||
priv->max_registered_pages = be64_to_cpu(descriptor->max_registered_pages);
|
||||
priv->tx_pages_per_qpl = be16_to_cpu(descriptor->tx_pages_per_qpl);
|
||||
priv->default_num_queues = be16_to_cpu(descriptor->default_num_queues);
|
||||
}
|
||||
|
||||
int gve_set_mtu(struct gve_priv *priv,
|
||||
struct gve_device_descriptor *descriptor)
|
||||
{
|
||||
u16 mtu;
|
||||
|
||||
mtu = be16_to_cpu(descriptor->mtu);
|
||||
if (mtu < ETH_MIN_MTU) {
|
||||
dev_err(&priv->pdev->dev, "MTU %d below minimum MTU\n", mtu);
|
||||
return -EINVAL;
|
||||
}
|
||||
priv->dev->max_mtu = mtu;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gve_set_mac(struct gve_priv *priv,
|
||||
struct gve_device_descriptor *descriptor)
|
||||
{
|
||||
u8 *mac;
|
||||
|
||||
mac = descriptor->mac;
|
||||
eth_hw_addr_set(priv->dev, mac);
|
||||
dev_info(&priv->pdev->dev, "MAC addr: %pM\n", mac);
|
||||
}
|
||||
|
||||
static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
|
||||
{
|
||||
int num_ntfy;
|
||||
int err;
|
||||
|
||||
/* Set up the adminq */
|
||||
@@ -2431,57 +2479,38 @@ static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
|
||||
"Could not get device information: err=%d\n", err);
|
||||
goto err;
|
||||
}
|
||||
priv->dev->mtu = priv->dev->max_mtu;
|
||||
num_ntfy = pci_msix_vec_count(priv->pdev);
|
||||
if (num_ntfy <= 0) {
|
||||
|
||||
err = gve_set_num_ntfy_blks(priv);
|
||||
if (err) {
|
||||
dev_err(&priv->pdev->dev,
|
||||
"could not count MSI-x vectors: err=%d\n", num_ntfy);
|
||||
err = num_ntfy;
|
||||
goto err;
|
||||
} else if (num_ntfy < GVE_MIN_MSIX) {
|
||||
dev_err(&priv->pdev->dev, "gve needs at least %d MSI-x vectors, but only has %d\n",
|
||||
GVE_MIN_MSIX, num_ntfy);
|
||||
err = -EINVAL;
|
||||
"Could not setup notify blocks: err=%d\n", err);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Big TCP is only supported on DQO */
|
||||
if (!gve_is_gqi(priv))
|
||||
netif_set_tso_max_size(priv->dev, GVE_DQO_TX_MAX);
|
||||
|
||||
priv->rx_copybreak = GVE_DEFAULT_RX_COPYBREAK;
|
||||
/* gvnic has one Notification Block per MSI-x vector, except for the
|
||||
* management vector
|
||||
*/
|
||||
priv->num_ntfy_blks = (num_ntfy - 1) & ~0x1;
|
||||
priv->mgmt_msix_idx = priv->num_ntfy_blks;
|
||||
priv->numa_node = dev_to_node(&priv->pdev->dev);
|
||||
|
||||
priv->tx_cfg.max_queues =
|
||||
min_t(int, priv->tx_cfg.max_queues, priv->num_ntfy_blks / 2);
|
||||
priv->rx_cfg.max_queues =
|
||||
min_t(int, priv->rx_cfg.max_queues, priv->num_ntfy_blks / 2);
|
||||
|
||||
priv->tx_cfg.num_queues = priv->tx_cfg.max_queues;
|
||||
priv->rx_cfg.num_queues = priv->rx_cfg.max_queues;
|
||||
if (priv->default_num_queues > 0) {
|
||||
priv->tx_cfg.num_queues = min_t(int, priv->default_num_queues,
|
||||
priv->tx_cfg.num_queues);
|
||||
priv->rx_cfg.num_queues = min_t(int, priv->default_num_queues,
|
||||
priv->rx_cfg.num_queues);
|
||||
}
|
||||
priv->tx_cfg.num_xdp_queues = 0;
|
||||
|
||||
gve_set_num_queues(priv);
|
||||
dev_info(&priv->pdev->dev, "TX queues %d, RX queues %d\n",
|
||||
priv->tx_cfg.num_queues, priv->rx_cfg.num_queues);
|
||||
dev_info(&priv->pdev->dev, "Max TX queues %d, Max RX queues %d\n",
|
||||
priv->tx_cfg.max_queues, priv->rx_cfg.max_queues);
|
||||
|
||||
if (!gve_is_gqi(priv)) {
|
||||
if (gve_is_dqo(priv)) {
|
||||
/* DQO supports HW-GRO and UDP_GSO */
|
||||
u64 additional_features = NETIF_F_GRO_HW | NETIF_F_GSO_UDP_L4;
|
||||
|
||||
priv->dev->hw_features |= additional_features;
|
||||
priv->dev->features |= additional_features;
|
||||
|
||||
priv->tx_coalesce_usecs = GVE_TX_IRQ_RATELIMIT_US_DQO;
|
||||
priv->rx_coalesce_usecs = GVE_RX_IRQ_RATELIMIT_US_DQO;
|
||||
|
||||
/* Big TCP is only supported on DQO */
|
||||
netif_set_tso_max_size(priv->dev, GVE_DQO_TX_MAX);
|
||||
}
|
||||
|
||||
priv->dev->mtu = priv->dev->max_mtu;
|
||||
priv->numa_node = dev_to_node(&priv->pdev->dev);
|
||||
priv->tx_cfg.num_xdp_queues = 0;
|
||||
priv->rx_copybreak = GVE_DEFAULT_RX_COPYBREAK;
|
||||
priv->ts_config.tx_type = HWTSTAMP_TX_OFF;
|
||||
priv->ts_config.rx_filter = HWTSTAMP_FILTER_NONE;
|
||||
|
||||
@@ -2506,14 +2535,14 @@ static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device)
|
||||
bitmap_free(priv->xsk_pools);
|
||||
priv->xsk_pools = NULL;
|
||||
err:
|
||||
gve_adminq_free(&priv->pdev->dev, priv);
|
||||
gve_adminq_free(priv);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void gve_teardown_priv_resources(struct gve_priv *priv)
|
||||
{
|
||||
gve_teardown_device_resources(priv);
|
||||
gve_adminq_free(&priv->pdev->dev, priv);
|
||||
gve_adminq_free(priv);
|
||||
bitmap_free(priv->xsk_pools);
|
||||
priv->xsk_pools = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user