Skip to content

Commit 1c325aa

Browse files
atbrady-intelanguy11
authored andcommitted
idpf: configure resources for TX queues
IDPF supports two queue models i.e. single queue which is a traditional queueing model as well as split queue model. In single queue model, the same descriptor queue is used by SW to post descriptors to the HW, HW to post completed descriptors to SW. In split queue model, "TX Queues" are used to pass buffers from SW to HW and "TX Completion Queues" are used to post descriptor completions from HW to SW. Device supports asymmetric ratio of TX queues to TX completion queues. Considering this, queue group mechanism is used i.e. some TX queues are grouped together which will be serviced by only one TX completion queue per TX queue group. Add all the resources required for the TX queues initialization. To start with, allocate memory for the TX queue groups, TX queues and TX completion queues. Then, allocate the descriptors for both TX and TX completion queues, and bookkeeping buffers for TX queues alone. Also, allocate queue vectors for the vport and initialize the TX queue related fields for each queue vector. Initialize the queue parameters such as q_id, q_type and tail register offset with the info received from the device control plane (CP). Once all the TX queues are configured, send config TX queue virtchnl message to the CP with all the TX queue context information. Signed-off-by: Alan Brady <[email protected]> Co-developed-by: Alice Michael <[email protected]> Signed-off-by: Alice Michael <[email protected]> Co-developed-by: Joshua Hay <[email protected]> Signed-off-by: Joshua Hay <[email protected]> Co-developed-by: Phani Burra <[email protected]> Signed-off-by: Phani Burra <[email protected]> Reviewed-by: Sridhar Samudrala <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Co-developed-by: Pavan Kumar Linga <[email protected]> Signed-off-by: Pavan Kumar Linga <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent ce1b75d commit 1c325aa

File tree

6 files changed

+1410
-0
lines changed

6 files changed

+1410
-0
lines changed

drivers/net/ethernet/intel/idpf/idpf.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ struct idpf_vport_max_q;
1515
#include <linux/pci.h>
1616

1717
#include "virtchnl2.h"
18+
#include "idpf_lan_txrx.h"
1819
#include "idpf_txrx.h"
1920
#include "idpf_controlq.h"
2021

22+
#define GETMAXVAL(num_bits) GENMASK((num_bits) - 1, 0)
23+
2124
#define IDPF_NO_FREE_SLOT 0xffff
2225

2326
/* Default Mailbox settings */
@@ -27,6 +30,8 @@ struct idpf_vport_max_q;
2730
#define IDPF_DFLT_MBX_ID -1
2831
/* maximum number of times to try before resetting mailbox */
2932
#define IDPF_MB_MAX_ERR 20
33+
#define IDPF_NUM_CHUNKS_PER_MSG(struct_sz, chunk_sz) \
34+
((IDPF_CTLQ_MAX_BUF_LEN - (struct_sz)) / (chunk_sz))
3035
#define IDPF_WAIT_FOR_EVENT_TIMEO_MIN 2000
3136
#define IDPF_WAIT_FOR_EVENT_TIMEO 60000
3237

@@ -201,6 +206,8 @@ struct idpf_dev_ops {
201206
STATE(IDPF_VC_CREATE_VPORT_ERR) \
202207
STATE(IDPF_VC_DESTROY_VPORT) \
203208
STATE(IDPF_VC_DESTROY_VPORT_ERR) \
209+
STATE(IDPF_VC_CONFIG_TXQ) \
210+
STATE(IDPF_VC_CONFIG_TXQ_ERR) \
204211
STATE(IDPF_VC_ALLOC_VECTORS) \
205212
STATE(IDPF_VC_ALLOC_VECTORS_ERR) \
206213
STATE(IDPF_VC_DEALLOC_VECTORS) \
@@ -229,7 +236,9 @@ extern const char * const idpf_vport_vc_state_str[];
229236
* @txq_desc_count: TX queue descriptor count
230237
* @complq_desc_count: Completion queue descriptor count
231238
* @num_txq_grp: Number of TX queue groups
239+
* @txq_grps: Array of TX queue groups
232240
* @txq_model: Split queue or single queue queuing model
241+
* @txqs: Used only in hotpath to get to the right queue very fast
233242
* @num_rxq: Number of allocated RX queues
234243
* @num_bufq: Number of allocated buffer queues
235244
* @rxq_desc_count: RX queue descriptor count. *MUST* have enough descriptors
@@ -249,6 +258,8 @@ extern const char * const idpf_vport_vc_state_str[];
249258
* @idx: Software index in adapter vports struct
250259
* @default_vport: Use this vport if one isn't specified
251260
* @base_rxd: True if the driver should use base descriptors instead of flex
261+
* @num_q_vectors: Number of IRQ vectors allocated
262+
* @q_vectors: Array of queue vectors
252263
* @max_mtu: device given max possible MTU
253264
* @default_mac_addr: device will give a default MAC to use
254265
* @vc_msg: Virtchnl message buffer
@@ -262,7 +273,10 @@ struct idpf_vport {
262273
u32 txq_desc_count;
263274
u32 complq_desc_count;
264275
u16 num_txq_grp;
276+
struct idpf_txq_group *txq_grps;
265277
u32 txq_model;
278+
struct idpf_queue **txqs;
279+
266280
u16 num_rxq;
267281
u16 num_bufq;
268282
u32 rxq_desc_count;
@@ -281,6 +295,8 @@ struct idpf_vport {
281295
bool default_vport;
282296
bool base_rxd;
283297

298+
u16 num_q_vectors;
299+
struct idpf_q_vector *q_vectors;
284300
u16 max_mtu;
285301
u8 default_mac_addr[ETH_ALEN];
286302

@@ -372,12 +388,14 @@ struct idpf_vector_lifo {
372388
* struct idpf_vport_config - Vport configuration data
373389
* @user_config: see struct idpf_vport_user_config_data
374390
* @max_q: Maximum possible queues
391+
* @req_qs_chunks: Queue chunk data for requested queues
375392
* @mac_filter_list_lock: Lock to protect mac filters
376393
* @flags: See enum idpf_vport_config_flags
377394
*/
378395
struct idpf_vport_config {
379396
struct idpf_vport_user_config_data user_config;
380397
struct idpf_vport_max_q max_q;
398+
void *req_qs_chunks;
381399
spinlock_t mac_filter_list_lock;
382400
DECLARE_BITMAP(flags, IDPF_VPORT_CONFIG_FLAGS_NBITS);
383401
};
@@ -577,6 +595,26 @@ static inline u16 idpf_get_max_vports(struct idpf_adapter *adapter)
577595
return le16_to_cpu(adapter->caps.max_vports);
578596
}
579597

598+
/**
599+
* idpf_get_max_tx_bufs - Get max scatter-gather buffers supported by the device
600+
* @adapter: private data struct
601+
*/
602+
static inline unsigned int idpf_get_max_tx_bufs(struct idpf_adapter *adapter)
603+
{
604+
return adapter->caps.max_sg_bufs_per_tx_pkt;
605+
}
606+
607+
/**
608+
* idpf_get_min_tx_pkt_len - Get min packet length supported by the device
609+
* @adapter: private data struct
610+
*/
611+
static inline u8 idpf_get_min_tx_pkt_len(struct idpf_adapter *adapter)
612+
{
613+
u8 pkt_len = adapter->caps.min_sso_packet_len;
614+
615+
return pkt_len ? pkt_len : IDPF_TX_MIN_PKT_LEN;
616+
}
617+
580618
/**
581619
* idpf_get_reg_addr - Get BAR0 register address
582620
* @adapter: private data struct
@@ -618,6 +656,42 @@ static inline bool idpf_is_reset_in_prog(struct idpf_adapter *adapter)
618656
test_bit(IDPF_HR_DRV_LOAD, adapter->flags));
619657
}
620658

659+
/**
660+
* idpf_netdev_to_vport - get a vport handle from a netdev
661+
* @netdev: network interface device structure
662+
*/
663+
static inline struct idpf_vport *idpf_netdev_to_vport(struct net_device *netdev)
664+
{
665+
struct idpf_netdev_priv *np = netdev_priv(netdev);
666+
667+
return np->vport;
668+
}
669+
670+
/**
671+
* idpf_vport_ctrl_lock - Acquire the vport control lock
672+
* @netdev: Network interface device structure
673+
*
674+
* This lock should be used by non-datapath code to protect against vport
675+
* destruction.
676+
*/
677+
static inline void idpf_vport_ctrl_lock(struct net_device *netdev)
678+
{
679+
struct idpf_netdev_priv *np = netdev_priv(netdev);
680+
681+
mutex_lock(&np->adapter->vport_ctrl_lock);
682+
}
683+
684+
/**
685+
* idpf_vport_ctrl_unlock - Release the vport control lock
686+
* @netdev: Network interface device structure
687+
*/
688+
static inline void idpf_vport_ctrl_unlock(struct net_device *netdev)
689+
{
690+
struct idpf_netdev_priv *np = netdev_priv(netdev);
691+
692+
mutex_unlock(&np->adapter->vport_ctrl_lock);
693+
}
694+
621695
void idpf_init_task(struct work_struct *work);
622696
void idpf_service_task(struct work_struct *work);
623697
void idpf_mbx_task(struct work_struct *work);
@@ -651,6 +725,9 @@ int idpf_add_del_mac_filters(struct idpf_vport *vport,
651725
bool add, bool async);
652726
void idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q);
653727
u32 idpf_get_vport_id(struct idpf_vport *vport);
728+
int idpf_vport_queue_ids_init(struct idpf_vport *vport);
729+
int idpf_queue_reg_init(struct idpf_vport *vport);
730+
int idpf_send_config_tx_queues_msg(struct idpf_vport *vport);
654731
int idpf_send_create_vport_msg(struct idpf_adapter *adapter,
655732
struct idpf_vport_max_q *max_q);
656733
int idpf_check_supported_desc_ids(struct idpf_vport *vport);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/* Copyright (C) 2023 Intel Corporation */
3+
4+
#ifndef _IDPF_LAN_TXRX_H_
5+
#define _IDPF_LAN_TXRX_H_
6+
7+
/* Transmit descriptors */
8+
/* splitq tx buf, singleq tx buf and singleq compl desc */
9+
struct idpf_base_tx_desc {
10+
__le64 buf_addr; /* Address of descriptor's data buf */
11+
__le64 qw1; /* type_cmd_offset_bsz_l2tag1 */
12+
}; /* read used with buffer queues */
13+
14+
struct idpf_splitq_tx_compl_desc {
15+
/* qid=[10:0] comptype=[13:11] rsvd=[14] gen=[15] */
16+
__le16 qid_comptype_gen;
17+
union {
18+
__le16 q_head; /* Queue head */
19+
__le16 compl_tag; /* Completion tag */
20+
} q_head_compl_tag;
21+
u8 ts[3];
22+
u8 rsvd; /* Reserved */
23+
}; /* writeback used with completion queues */
24+
25+
#endif /* _IDPF_LAN_TXRX_H_ */

0 commit comments

Comments
 (0)