mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 15:43:08 -04:00
gve: add a few helper functions to set device properties
For the mailbox ABI, device properties will come from a different source compared to the AdminQ mode. To accommodate the new source when the mailbox ABI is added, add a few helper functions to set a few device properties. Those functions are: - gve_set_queue_properties() to set no. of pages for QPL mode and number of queues in general - gve_set_mtu() - gve_set_mac() This is just code movement, no functional change. Reviewed-by: Willem de Bruijn <willemb@google.com> Reviewed-by: Jordan Rhee <jordanrhee@google.com> Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Link: https://patch.msgid.link/20260814021406.3044324-4-hramamurthy@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
94afe5cebc
commit
69886e8085
@@ -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,26 +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);
|
||||
|
||||
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,
|
||||
|
||||
@@ -658,5 +658,10 @@ 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,6 +2398,55 @@ 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 err;
|
||||
|
||||
Reference in New Issue
Block a user