Commit 116af5f2 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files
Tony Nguyen says:

====================
refactor IDPF resource access

Pavan Kumar Linga says:

Queue and vector resources for a given vport, are stored in the
idpf_vport structure. At the time of configuration, these
resources are accessed using vport pointer. Meaning, all the
config path functions are tied to the default queue and vector
resources of the vport.

There are use cases which can make use of config path functions
to configure queue and vector resources that are not tied to any
vport. One such use case is PTP secondary mailbox creation
(it would be in a followup series). To configure queue and interrupt
resources for such cases, we can make use of the existing config
infrastructure by passing the necessary queue and vector resources info.

To achieve this, group the existing queue and vector resources into
default resource group and refactor the code to pass the resource
pointer to the config path functions.

This series also includes patches which generalizes the send virtchnl
message APIs and mailbox API that are necessary for the implementation
of PTP secondary mailbox.

* '200GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue:
  idpf: generalize mailbox API
  idpf: avoid calling get_rx_ptypes for each vport
  idpf: generalize send virtchnl message API
  idpf: remove vport pointer from queue sets
  idpf: add rss_data field to RSS function parameters
  idpf: reshuffle idpf_vport struct members to avoid holes
  idpf: move some iterator declarations inside for loops
  idpf: move queue resources to idpf_q_vec_rsrc structure
  idpf: introduce idpf_q_vec_rsrc struct and move vector resources to it
  idpf: introduce local idpf structure to store virtchnl queue chunks
====================

Link: https://patch.msgid.link/20260122223601.2208759-1-anthony.l.nguyen@intel.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 4a7bbaa6 086d030e
Loading
Loading
Loading
Loading
+111 −68
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@
struct idpf_adapter;
struct idpf_vport;
struct idpf_vport_max_q;
struct idpf_q_vec_rsrc;
struct idpf_rss_data;

#include <net/pkt_sched.h>
#include <linux/aer.h>
@@ -201,7 +203,8 @@ struct idpf_vport_max_q {
struct idpf_reg_ops {
	void (*ctlq_reg_init)(struct idpf_adapter *adapter,
			      struct idpf_ctlq_create_info *cq);
	int (*intr_reg_init)(struct idpf_vport *vport);
	int (*intr_reg_init)(struct idpf_vport *vport,
			     struct idpf_q_vec_rsrc *rsrc);
	void (*mb_intr_reg_init)(struct idpf_adapter *adapter);
	void (*reset_reg_init)(struct idpf_adapter *adapter);
	void (*trigger_reset)(struct idpf_adapter *adapter,
@@ -288,54 +291,88 @@ struct idpf_fsteer_fltr {
};

/**
 * struct idpf_vport - Handle for netdevices and queue resources
 * @num_txq: Number of allocated TX queues
 * @num_complq: Number of allocated completion queues
 * struct idpf_q_vec_rsrc - handle for queue and vector resources
 * @dev: device pointer for DMA mapping
 * @q_vectors: array of queue vectors
 * @q_vector_idxs: starting index of queue vectors
 * @num_q_vectors: number of IRQ vectors allocated
 * @noirq_v_idx: ID of the NOIRQ vector
 * @noirq_dyn_ctl_ena: value to write to the above to enable it
 * @noirq_dyn_ctl: register to enable/disable the vector for NOIRQ queues
 * @txq_grps: array of TX queue groups
 * @txq_desc_count: TX queue descriptor count
 * @complq_desc_count: Completion queue descriptor count
 * @compln_clean_budget: Work budget for completion clean
 * @num_txq_grp: Number of TX queue groups
 * @txq_grps: Array of TX queue groups
 * @txq_model: Split queue or single queue queuing model
 * @txqs: Used only in hotpath to get to the right queue very fast
 * @crc_enable: Enable CRC insertion offload
 * @xdpsq_share: whether XDPSQ sharing is enabled
 * @num_xdp_txq: number of XDPSQs
 * @complq_desc_count: completion queue descriptor count
 * @txq_model: split queue or single queue queuing model
 * @num_txq: number of allocated TX queues
 * @num_complq: number of allocated completion queues
 * @num_txq_grp: number of TX queue groups
 * @xdp_txq_offset: index of the first XDPSQ (== number of regular SQs)
 * @xdp_prog: installed XDP program
 * @num_rxq: Number of allocated RX queues
 * @num_bufq: Number of allocated buffer queues
 * @num_rxq_grp: number of RX queues in a group
 * @rxq_model: splitq queue or single queue queuing model
 * @rxq_grps: total number of RX groups. Number of groups * number of RX per
 *	      group will yield total number of RX queues.
 * @num_rxq: number of allocated RX queues
 * @num_bufq: number of allocated buffer queues
 * @rxq_desc_count: RX queue descriptor count. *MUST* have enough descriptors
 *		    to complete all buffer descriptors for all buffer queues in
 *		    the worst case.
 * @num_bufqs_per_qgrp: Buffer queues per RX queue in a given grouping
 * @bufq_desc_count: Buffer queue descriptor count
 * @num_rxq_grp: Number of RX queues in a group
 * @rxq_grps: Total number of RX groups. Number of groups * number of RX per
 *	      group will yield total number of RX queues.
 * @rxq_model: Splitq queue or single queue queuing model
 * @rx_ptype_lkup: Lookup table for ptypes on RX
 * @bufq_desc_count: buffer queue descriptor count
 * @num_bufqs_per_qgrp: buffer queues per RX queue in a given grouping
 * @base_rxd: true if the driver should use base descriptors instead of flex
 */
struct idpf_q_vec_rsrc {
	struct device		*dev;
	struct idpf_q_vector	*q_vectors;
	u16			*q_vector_idxs;
	u16			num_q_vectors;
	u16			noirq_v_idx;
	u32			noirq_dyn_ctl_ena;
	void __iomem		*noirq_dyn_ctl;

	struct idpf_txq_group	*txq_grps;
	u32			txq_desc_count;
	u32			complq_desc_count;
	u32			txq_model;
	u16			num_txq;
	u16			num_complq;
	u16			num_txq_grp;
	u16			xdp_txq_offset;

	u16			num_rxq_grp;
	u32			rxq_model;
	struct idpf_rxq_group	*rxq_grps;
	u16			num_rxq;
	u16			num_bufq;
	u32			rxq_desc_count;
	u32			bufq_desc_count[IDPF_MAX_BUFQS_PER_RXQ_GRP];
	u8			num_bufqs_per_qgrp;
	bool			base_rxd;
};

/**
 * struct idpf_vport - Handle for netdevices and queue resources
 * @dflt_qv_rsrc: contains default queue and vector resources
 * @txqs: Used only in hotpath to get to the right queue very fast
 * @num_txq: Number of allocated TX queues
 * @num_xdp_txq: number of XDPSQs
 * @xdpsq_share: whether XDPSQ sharing is enabled
 * @xdp_prog: installed XDP program
 * @vdev_info: IDC vport device info pointer
 * @adapter: back pointer to associated adapter
 * @netdev: Associated net_device. Each vport should have one and only one
 *	    associated netdev.
 * @flags: See enum idpf_vport_flags
 * @vport_type: Default SRIOV, SIOV, etc.
 * @compln_clean_budget: Work budget for completion clean
 * @vport_id: Device given vport identifier
 * @vport_type: Default SRIOV, SIOV, etc.
 * @idx: Software index in adapter vports struct
 * @default_vport: Use this vport if one isn't specified
 * @base_rxd: True if the driver should use base descriptors instead of flex
 * @num_q_vectors: Number of IRQ vectors allocated
 * @q_vectors: Array of queue vectors
 * @q_vector_idxs: Starting index of queue vectors
 * @noirq_dyn_ctl: register to enable/disable the vector for NOIRQ queues
 * @noirq_dyn_ctl_ena: value to write to the above to enable it
 * @noirq_v_idx: ID of the NOIRQ vector
 * @max_mtu: device given max possible MTU
 * @default_mac_addr: device will give a default MAC to use
 * @rx_itr_profile: RX profiles for Dynamic Interrupt Moderation
 * @tx_itr_profile: TX profiles for Dynamic Interrupt Moderation
 * @port_stats: per port csum, header split, and other offload stats
 * @default_vport: Use this vport if one isn't specified
 * @crc_enable: Enable CRC insertion offload
 * @link_up: True if link is up
 * @tx_tstamp_caps: Capabilities negotiated for Tx timestamping
 * @tstamp_config: The Tx tstamp config
@@ -343,57 +380,31 @@ struct idpf_fsteer_fltr {
 * @tstamp_stats: Tx timestamping statistics
 */
struct idpf_vport {
	u16 num_txq;
	u16 num_complq;
	u32 txq_desc_count;
	u32 complq_desc_count;
	u32 compln_clean_budget;
	u16 num_txq_grp;
	struct idpf_txq_group *txq_grps;
	u32 txq_model;
	struct idpf_q_vec_rsrc dflt_qv_rsrc;
	struct idpf_tx_queue **txqs;
	bool crc_enable;

	bool xdpsq_share;
	u16 num_txq;
	u16 num_xdp_txq;
	u16 xdp_txq_offset;
	bool xdpsq_share;
	struct bpf_prog *xdp_prog;

	u16 num_rxq;
	u16 num_bufq;
	u32 rxq_desc_count;
	u8 num_bufqs_per_qgrp;
	u32 bufq_desc_count[IDPF_MAX_BUFQS_PER_RXQ_GRP];
	u16 num_rxq_grp;
	struct idpf_rxq_group *rxq_grps;
	u32 rxq_model;
	struct libeth_rx_pt *rx_ptype_lkup;

	struct iidc_rdma_vport_dev_info *vdev_info;

	struct idpf_adapter *adapter;
	struct net_device *netdev;
	DECLARE_BITMAP(flags, IDPF_VPORT_FLAGS_NBITS);
	u16 vport_type;
	u32 compln_clean_budget;
	u32 vport_id;
	u16 vport_type;
	u16 idx;
	bool default_vport;
	bool base_rxd;

	u16 num_q_vectors;
	struct idpf_q_vector *q_vectors;
	u16 *q_vector_idxs;

	void __iomem *noirq_dyn_ctl;
	u32 noirq_dyn_ctl_ena;
	u16 noirq_v_idx;

	u16 max_mtu;
	u8 default_mac_addr[ETH_ALEN];
	u16 rx_itr_profile[IDPF_DIM_PROFILE_SLOTS];
	u16 tx_itr_profile[IDPF_DIM_PROFILE_SLOTS];
	struct idpf_port_stats port_stats;

	struct idpf_port_stats port_stats;
	bool default_vport;
	bool crc_enable;
	bool link_up;

	struct idpf_ptp_vport_tx_tstamp_caps *tx_tstamp_caps;
@@ -549,11 +560,38 @@ struct idpf_vector_lifo {
	u16 *vec_idx;
};

/**
 * struct idpf_queue_id_reg_chunk - individual queue ID and register chunk
 * @qtail_reg_start: queue tail register offset
 * @qtail_reg_spacing: queue tail register spacing
 * @type: queue type of the queues in the chunk
 * @start_queue_id: starting queue ID in the chunk
 * @num_queues: number of queues in the chunk
 */
struct idpf_queue_id_reg_chunk {
	u64 qtail_reg_start;
	u32 qtail_reg_spacing;
	u32 type;
	u32 start_queue_id;
	u32 num_queues;
};

/**
 * struct idpf_queue_id_reg_info - queue ID and register chunk info received
 *				   over the mailbox
 * @num_chunks: number of chunks
 * @queue_chunks: array of chunks
 */
struct idpf_queue_id_reg_info {
	u16 num_chunks;
	struct idpf_queue_id_reg_chunk *queue_chunks;
};

/**
 * struct idpf_vport_config - Vport configuration data
 * @user_config: see struct idpf_vport_user_config_data
 * @max_q: Maximum possible queues
 * @req_qs_chunks: Queue chunk data for requested queues
 * @qid_reg_info: Struct to store the queue ID and register info
 * @mac_filter_list_lock: Lock to protect mac filters
 * @flow_steer_list_lock: Lock to protect fsteer filters
 * @flags: See enum idpf_vport_config_flags
@@ -561,7 +599,7 @@ struct idpf_vector_lifo {
struct idpf_vport_config {
	struct idpf_vport_user_config_data user_config;
	struct idpf_vport_max_q max_q;
	struct virtchnl2_add_queues *req_qs_chunks;
	struct idpf_queue_id_reg_info qid_reg_info;
	spinlock_t mac_filter_list_lock;
	spinlock_t flow_steer_list_lock;
	DECLARE_BITMAP(flags, IDPF_VPORT_CONFIG_FLAGS_NBITS);
@@ -603,6 +641,8 @@ struct idpf_vc_xn_manager;
 * @vport_params_reqd: Vport params requested
 * @vport_params_recvd: Vport params received
 * @vport_ids: Array of device given vport identifiers
 * @singleq_pt_lkup: Lookup table for singleq RX ptypes
 * @splitq_pt_lkup: Lookup table for splitq RX ptypes
 * @vport_config: Vport config parameters
 * @max_vports: Maximum vports that can be allocated
 * @num_alloc_vports: Current number of vports allocated
@@ -661,6 +701,9 @@ struct idpf_adapter {
	struct virtchnl2_create_vport **vport_params_recvd;
	u32 *vport_ids;

	struct libeth_rx_pt *singleq_pt_lkup;
	struct libeth_rx_pt *splitq_pt_lkup;

	struct idpf_vport_config **vport_config;
	u16 max_vports;
	u16 num_alloc_vports;
+10 −8
Original line number Diff line number Diff line
@@ -70,11 +70,13 @@ static void idpf_mb_intr_reg_init(struct idpf_adapter *adapter)
/**
 * idpf_intr_reg_init - Initialize interrupt registers
 * @vport: virtual port structure
 * @rsrc: pointer to queue and vector resources
 */
static int idpf_intr_reg_init(struct idpf_vport *vport)
static int idpf_intr_reg_init(struct idpf_vport *vport,
			      struct idpf_q_vec_rsrc *rsrc)
{
	struct idpf_adapter *adapter = vport->adapter;
	int num_vecs = vport->num_q_vectors;
	u16 num_vecs = rsrc->num_q_vectors;
	struct idpf_vec_regs *reg_vals;
	int num_regs, i, err = 0;
	u32 rx_itr, tx_itr, val;
@@ -86,15 +88,15 @@ static int idpf_intr_reg_init(struct idpf_vport *vport)
	if (!reg_vals)
		return -ENOMEM;

	num_regs = idpf_get_reg_intr_vecs(vport, reg_vals);
	num_regs = idpf_get_reg_intr_vecs(adapter, reg_vals);
	if (num_regs < num_vecs) {
		err = -EINVAL;
		goto free_reg_vals;
	}

	for (i = 0; i < num_vecs; i++) {
		struct idpf_q_vector *q_vector = &vport->q_vectors[i];
		u16 vec_id = vport->q_vector_idxs[i] - IDPF_MBX_Q_VEC;
		struct idpf_q_vector *q_vector = &rsrc->q_vectors[i];
		u16 vec_id = rsrc->q_vector_idxs[i] - IDPF_MBX_Q_VEC;
		struct idpf_intr_reg *intr = &q_vector->intr_reg;
		u32 spacing;

@@ -123,12 +125,12 @@ static int idpf_intr_reg_init(struct idpf_vport *vport)

	/* Data vector for NOIRQ queues */

	val = reg_vals[vport->q_vector_idxs[i] - IDPF_MBX_Q_VEC].dyn_ctl_reg;
	vport->noirq_dyn_ctl = idpf_get_reg_addr(adapter, val);
	val = reg_vals[rsrc->q_vector_idxs[i] - IDPF_MBX_Q_VEC].dyn_ctl_reg;
	rsrc->noirq_dyn_ctl = idpf_get_reg_addr(adapter, val);

	val = PF_GLINT_DYN_CTL_WB_ON_ITR_M | PF_GLINT_DYN_CTL_INTENA_MSK_M |
	      FIELD_PREP(PF_GLINT_DYN_CTL_ITR_INDX_M, IDPF_NO_ITR_UPDATE_IDX);
	vport->noirq_dyn_ctl_ena = val;
	rsrc->noirq_dyn_ctl_ena = val;

free_reg_vals:
	kfree(reg_vals);
+52 −41
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ static u32 idpf_get_rx_ring_count(struct net_device *netdev)

	idpf_vport_ctrl_lock(netdev);
	vport = idpf_netdev_to_vport(netdev);
	num_rxq = vport->num_rxq;
	num_rxq = vport->dflt_qv_rsrc.num_rxq;
	idpf_vport_ctrl_unlock(netdev);

	return num_rxq;
@@ -503,7 +503,7 @@ static int idpf_set_rxfh(struct net_device *netdev,
	}

	if (test_bit(IDPF_VPORT_UP, np->state))
		err = idpf_config_rss(vport);
		err = idpf_config_rss(vport, rss_data);

unlock_mutex:
	idpf_vport_ctrl_unlock(netdev);
@@ -644,8 +644,8 @@ static void idpf_get_ringparam(struct net_device *netdev,

	ring->rx_max_pending = IDPF_MAX_RXQ_DESC;
	ring->tx_max_pending = IDPF_MAX_TXQ_DESC;
	ring->rx_pending = vport->rxq_desc_count;
	ring->tx_pending = vport->txq_desc_count;
	ring->rx_pending = vport->dflt_qv_rsrc.rxq_desc_count;
	ring->tx_pending = vport->dflt_qv_rsrc.txq_desc_count;

	kring->tcp_data_split = idpf_vport_get_hsplit(vport);

@@ -669,8 +669,9 @@ static int idpf_set_ringparam(struct net_device *netdev,
{
	struct idpf_vport_user_config_data *config_data;
	u32 new_rx_count, new_tx_count;
	struct idpf_q_vec_rsrc *rsrc;
	struct idpf_vport *vport;
	int i, err = 0;
	int err = 0;
	u16 idx;

	idpf_vport_ctrl_lock(netdev);
@@ -704,8 +705,9 @@ static int idpf_set_ringparam(struct net_device *netdev,
		netdev_info(netdev, "Requested Tx descriptor count rounded up to %u\n",
			    new_tx_count);

	if (new_tx_count == vport->txq_desc_count &&
	    new_rx_count == vport->rxq_desc_count &&
	rsrc = &vport->dflt_qv_rsrc;
	if (new_tx_count == rsrc->txq_desc_count &&
	    new_rx_count == rsrc->rxq_desc_count &&
	    kring->tcp_data_split == idpf_vport_get_hsplit(vport))
		goto unlock_mutex;

@@ -724,10 +726,10 @@ static int idpf_set_ringparam(struct net_device *netdev,
	/* Since we adjusted the RX completion queue count, the RX buffer queue
	 * descriptor count needs to be adjusted as well
	 */
	for (i = 0; i < vport->num_bufqs_per_qgrp; i++)
		vport->bufq_desc_count[i] =
	for (unsigned int i = 0; i < rsrc->num_bufqs_per_qgrp; i++)
		rsrc->bufq_desc_count[i] =
			IDPF_RX_BUFQ_DESC_COUNT(new_rx_count,
						vport->num_bufqs_per_qgrp);
						rsrc->num_bufqs_per_qgrp);

	err = idpf_initiate_soft_reset(vport, IDPF_SR_Q_DESC_CHANGE);

@@ -1104,7 +1106,7 @@ static void idpf_add_port_stats(struct idpf_vport *vport, u64 **data)
static void idpf_collect_queue_stats(struct idpf_vport *vport)
{
	struct idpf_port_stats *pstats = &vport->port_stats;
	int i, j;
	struct idpf_q_vec_rsrc *rsrc = &vport->dflt_qv_rsrc;

	/* zero out port stats since they're actually tracked in per
	 * queue stats; this is only for reporting
@@ -1120,22 +1122,22 @@ static void idpf_collect_queue_stats(struct idpf_vport *vport)
	u64_stats_set(&pstats->tx_dma_map_errs, 0);
	u64_stats_update_end(&pstats->stats_sync);

	for (i = 0; i < vport->num_rxq_grp; i++) {
		struct idpf_rxq_group *rxq_grp = &vport->rxq_grps[i];
	for (unsigned int i = 0; i < rsrc->num_rxq_grp; i++) {
		struct idpf_rxq_group *rxq_grp = &rsrc->rxq_grps[i];
		u16 num_rxq;

		if (idpf_is_queue_model_split(vport->rxq_model))
		if (idpf_is_queue_model_split(rsrc->rxq_model))
			num_rxq = rxq_grp->splitq.num_rxq_sets;
		else
			num_rxq = rxq_grp->singleq.num_rxq;

		for (j = 0; j < num_rxq; j++) {
		for (unsigned int j = 0; j < num_rxq; j++) {
			u64 hw_csum_err, hsplit, hsplit_hbo, bad_descs;
			struct idpf_rx_queue_stats *stats;
			struct idpf_rx_queue *rxq;
			unsigned int start;

			if (idpf_is_queue_model_split(vport->rxq_model))
			if (idpf_is_queue_model_split(rsrc->rxq_model))
				rxq = &rxq_grp->splitq.rxq_sets[j]->rxq;
			else
				rxq = rxq_grp->singleq.rxqs[j];
@@ -1162,10 +1164,10 @@ static void idpf_collect_queue_stats(struct idpf_vport *vport)
		}
	}

	for (i = 0; i < vport->num_txq_grp; i++) {
		struct idpf_txq_group *txq_grp = &vport->txq_grps[i];
	for (unsigned int i = 0; i < rsrc->num_txq_grp; i++) {
		struct idpf_txq_group *txq_grp = &rsrc->txq_grps[i];

		for (j = 0; j < txq_grp->num_txq; j++) {
		for (unsigned int j = 0; j < txq_grp->num_txq; j++) {
			u64 linearize, qbusy, skb_drops, dma_map_errs;
			struct idpf_tx_queue *txq = txq_grp->txqs[j];
			struct idpf_tx_queue_stats *stats;
@@ -1208,9 +1210,9 @@ static void idpf_get_ethtool_stats(struct net_device *netdev,
{
	struct idpf_netdev_priv *np = netdev_priv(netdev);
	struct idpf_vport_config *vport_config;
	struct idpf_q_vec_rsrc *rsrc;
	struct idpf_vport *vport;
	unsigned int total = 0;
	unsigned int i, j;
	bool is_splitq;
	u16 qtype;

@@ -1228,12 +1230,13 @@ static void idpf_get_ethtool_stats(struct net_device *netdev,
	idpf_collect_queue_stats(vport);
	idpf_add_port_stats(vport, &data);

	for (i = 0; i < vport->num_txq_grp; i++) {
		struct idpf_txq_group *txq_grp = &vport->txq_grps[i];
	rsrc = &vport->dflt_qv_rsrc;
	for (unsigned int i = 0; i < rsrc->num_txq_grp; i++) {
		struct idpf_txq_group *txq_grp = &rsrc->txq_grps[i];

		qtype = VIRTCHNL2_QUEUE_TYPE_TX;

		for (j = 0; j < txq_grp->num_txq; j++, total++) {
		for (unsigned int j = 0; j < txq_grp->num_txq; j++, total++) {
			struct idpf_tx_queue *txq = txq_grp->txqs[j];

			if (!txq)
@@ -1253,10 +1256,10 @@ static void idpf_get_ethtool_stats(struct net_device *netdev,
		idpf_add_empty_queue_stats(&data, VIRTCHNL2_QUEUE_TYPE_TX);
	total = 0;

	is_splitq = idpf_is_queue_model_split(vport->rxq_model);
	is_splitq = idpf_is_queue_model_split(rsrc->rxq_model);

	for (i = 0; i < vport->num_rxq_grp; i++) {
		struct idpf_rxq_group *rxq_grp = &vport->rxq_grps[i];
	for (unsigned int i = 0; i < rsrc->num_rxq_grp; i++) {
		struct idpf_rxq_group *rxq_grp = &rsrc->rxq_grps[i];
		u16 num_rxq;

		qtype = VIRTCHNL2_QUEUE_TYPE_RX;
@@ -1266,7 +1269,7 @@ static void idpf_get_ethtool_stats(struct net_device *netdev,
		else
			num_rxq = rxq_grp->singleq.num_rxq;

		for (j = 0; j < num_rxq; j++, total++) {
		for (unsigned int j = 0; j < num_rxq; j++, total++) {
			struct idpf_rx_queue *rxq;

			if (is_splitq)
@@ -1298,15 +1301,16 @@ static void idpf_get_ethtool_stats(struct net_device *netdev,
struct idpf_q_vector *idpf_find_rxq_vec(const struct idpf_vport *vport,
					u32 q_num)
{
	const struct idpf_q_vec_rsrc *rsrc = &vport->dflt_qv_rsrc;
	int q_grp, q_idx;

	if (!idpf_is_queue_model_split(vport->rxq_model))
		return vport->rxq_grps->singleq.rxqs[q_num]->q_vector;
	if (!idpf_is_queue_model_split(rsrc->rxq_model))
		return rsrc->rxq_grps->singleq.rxqs[q_num]->q_vector;

	q_grp = q_num / IDPF_DFLT_SPLITQ_RXQ_PER_GROUP;
	q_idx = q_num % IDPF_DFLT_SPLITQ_RXQ_PER_GROUP;

	return vport->rxq_grps[q_grp].splitq.rxq_sets[q_idx]->rxq.q_vector;
	return rsrc->rxq_grps[q_grp].splitq.rxq_sets[q_idx]->rxq.q_vector;
}

/**
@@ -1319,14 +1323,15 @@ struct idpf_q_vector *idpf_find_rxq_vec(const struct idpf_vport *vport,
struct idpf_q_vector *idpf_find_txq_vec(const struct idpf_vport *vport,
					u32 q_num)
{
	const struct idpf_q_vec_rsrc *rsrc = &vport->dflt_qv_rsrc;
	int q_grp;

	if (!idpf_is_queue_model_split(vport->txq_model))
	if (!idpf_is_queue_model_split(rsrc->txq_model))
		return vport->txqs[q_num]->q_vector;

	q_grp = q_num / IDPF_DFLT_SPLITQ_TXQ_PER_GROUP;

	return vport->txq_grps[q_grp].complq->q_vector;
	return rsrc->txq_grps[q_grp].complq->q_vector;
}

/**
@@ -1363,7 +1368,8 @@ static int idpf_get_q_coalesce(struct net_device *netdev,
			       u32 q_num)
{
	const struct idpf_netdev_priv *np = netdev_priv(netdev);
	const struct idpf_vport *vport;
	struct idpf_q_vec_rsrc *rsrc;
	struct idpf_vport *vport;
	int err = 0;

	idpf_vport_ctrl_lock(netdev);
@@ -1372,16 +1378,17 @@ static int idpf_get_q_coalesce(struct net_device *netdev,
	if (!test_bit(IDPF_VPORT_UP, np->state))
		goto unlock_mutex;

	if (q_num >= vport->num_rxq && q_num >= vport->num_txq) {
	rsrc = &vport->dflt_qv_rsrc;
	if (q_num >= rsrc->num_rxq && q_num >= rsrc->num_txq) {
		err = -EINVAL;
		goto unlock_mutex;
	}

	if (q_num < vport->num_rxq)
	if (q_num < rsrc->num_rxq)
		__idpf_get_q_coalesce(ec, idpf_find_rxq_vec(vport, q_num),
				      VIRTCHNL2_QUEUE_TYPE_RX);

	if (q_num < vport->num_txq)
	if (q_num < rsrc->num_txq)
		__idpf_get_q_coalesce(ec, idpf_find_txq_vec(vport, q_num),
				      VIRTCHNL2_QUEUE_TYPE_TX);

@@ -1549,8 +1556,9 @@ static int idpf_set_coalesce(struct net_device *netdev,
	struct idpf_netdev_priv *np = netdev_priv(netdev);
	struct idpf_vport_user_config_data *user_config;
	struct idpf_q_coalesce *q_coal;
	struct idpf_q_vec_rsrc *rsrc;
	struct idpf_vport *vport;
	int i, err = 0;
	int err = 0;

	user_config = &np->adapter->vport_config[np->vport_idx]->user_config;

@@ -1560,14 +1568,15 @@ static int idpf_set_coalesce(struct net_device *netdev,
	if (!test_bit(IDPF_VPORT_UP, np->state))
		goto unlock_mutex;

	for (i = 0; i < vport->num_txq; i++) {
	rsrc = &vport->dflt_qv_rsrc;
	for (unsigned int i = 0; i < rsrc->num_txq; i++) {
		q_coal = &user_config->q_coalesce[i];
		err = idpf_set_q_coalesce(vport, q_coal, ec, i, false);
		if (err)
			goto unlock_mutex;
	}

	for (i = 0; i < vport->num_rxq; i++) {
	for (unsigned int i = 0; i < rsrc->num_rxq; i++) {
		q_coal = &user_config->q_coalesce[i];
		err = idpf_set_q_coalesce(vport, q_coal, ec, i, true);
		if (err)
@@ -1748,6 +1757,7 @@ static void idpf_get_ts_stats(struct net_device *netdev,
			      struct ethtool_ts_stats *ts_stats)
{
	struct idpf_netdev_priv *np = netdev_priv(netdev);
	struct idpf_q_vec_rsrc *rsrc;
	struct idpf_vport *vport;
	unsigned int start;

@@ -1763,8 +1773,9 @@ static void idpf_get_ts_stats(struct net_device *netdev,
	if (!test_bit(IDPF_VPORT_UP, np->state))
		goto exit;

	for (u16 i = 0; i < vport->num_txq_grp; i++) {
		struct idpf_txq_group *txq_grp = &vport->txq_grps[i];
	rsrc = &vport->dflt_qv_rsrc;
	for (u16 i = 0; i < rsrc->num_txq_grp; i++) {
		struct idpf_txq_group *txq_grp = &rsrc->txq_grps[i];

		for (u16 j = 0; j < txq_grp->num_txq; j++) {
			struct idpf_tx_queue *txq = txq_grp->txqs[j];
+130 −95

File changed.

Preview size limit exceeded, changes collapsed.

+10 −7
Original line number Diff line number Diff line
@@ -384,15 +384,17 @@ static int idpf_ptp_update_cached_phctime(struct idpf_adapter *adapter)
	WRITE_ONCE(adapter->ptp->cached_phc_jiffies, jiffies);

	idpf_for_each_vport(adapter, vport) {
		struct idpf_q_vec_rsrc *rsrc;
		bool split;

		if (!vport || !vport->rxq_grps)
		if (!vport || !vport->dflt_qv_rsrc.rxq_grps)
			continue;

		split = idpf_is_queue_model_split(vport->rxq_model);
		rsrc = &vport->dflt_qv_rsrc;
		split = idpf_is_queue_model_split(rsrc->rxq_model);

		for (u16 i = 0; i < vport->num_rxq_grp; i++) {
			struct idpf_rxq_group *grp = &vport->rxq_grps[i];
		for (u16 i = 0; i < rsrc->num_rxq_grp; i++) {
			struct idpf_rxq_group *grp = &rsrc->rxq_grps[i];

			idpf_ptp_update_phctime_rxq_grp(grp, split, systime);
		}
@@ -681,9 +683,10 @@ int idpf_ptp_request_ts(struct idpf_tx_queue *tx_q, struct sk_buff *skb,
 */
static void idpf_ptp_set_rx_tstamp(struct idpf_vport *vport, int rx_filter)
{
	struct idpf_q_vec_rsrc *rsrc = &vport->dflt_qv_rsrc;
	bool enable = true, splitq;

	splitq = idpf_is_queue_model_split(vport->rxq_model);
	splitq = idpf_is_queue_model_split(rsrc->rxq_model);

	if (rx_filter == HWTSTAMP_FILTER_NONE) {
		enable = false;
@@ -692,8 +695,8 @@ static void idpf_ptp_set_rx_tstamp(struct idpf_vport *vport, int rx_filter)
		vport->tstamp_config.rx_filter = HWTSTAMP_FILTER_ALL;
	}

	for (u16 i = 0; i < vport->num_rxq_grp; i++) {
		struct idpf_rxq_group *grp = &vport->rxq_grps[i];
	for (u16 i = 0; i < rsrc->num_rxq_grp; i++) {
		struct idpf_rxq_group *grp = &rsrc->rxq_grps[i];
		struct idpf_rx_queue *rx_queue;
		u16 j, num_rxq;

Loading