Skip to content

Commit 02cbfba

Browse files
atbrady-intelanguy11
authored andcommitted
idpf: add ethtool callbacks
Initialize all the ethtool ops that are supported by the driver and add the necessary support for the ethtool callbacks. Also add asynchronous link notification virtchnl support where the device Control Plane sends the link status and link speed as an asynchronous event message. Driver report the link speed on ethtool .idpf_get_link_ksettings query. Introduce soft reset function which is used by some of the ethtool callbacks such as .set_channels, .set_ringparam etc. to change the existing queue configuration. It deletes the existing queues by sending delete queues virtchnl message to the CP and calls the 'vport_stop' flow which disables the queues, vport etc. New set of queues are requested to the CP and reconfigure the queue context by calling the 'vport_open' flow. Soft reset flow also adjusts the number of vectors associated to a vport if .set_channels is called. 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 a5ab9ee commit 02cbfba

File tree

7 files changed

+1851
-3
lines changed

7 files changed

+1851
-3
lines changed

drivers/net/ethernet/intel/idpf/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ idpf-y := \
99
idpf_controlq.o \
1010
idpf_controlq_setup.o \
1111
idpf_dev.o \
12+
idpf_ethtool.o \
1213
idpf_lib.o \
1314
idpf_main.o \
1415
idpf_singleq_txrx.o \

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct idpf_vport_max_q;
1515
#include <linux/pci.h>
1616
#include <linux/bitfield.h>
1717
#include <linux/sctp.h>
18+
#include <linux/ethtool.h>
1819
#include <net/gro.h>
1920
#include <linux/dim.h>
2021

@@ -230,6 +231,10 @@ struct idpf_dev_ops {
230231
STATE(IDPF_VC_MAP_IRQ_ERR) \
231232
STATE(IDPF_VC_UNMAP_IRQ) \
232233
STATE(IDPF_VC_UNMAP_IRQ_ERR) \
234+
STATE(IDPF_VC_ADD_QUEUES) \
235+
STATE(IDPF_VC_ADD_QUEUES_ERR) \
236+
STATE(IDPF_VC_DEL_QUEUES) \
237+
STATE(IDPF_VC_DEL_QUEUES_ERR) \
233238
STATE(IDPF_VC_ALLOC_VECTORS) \
234239
STATE(IDPF_VC_ALLOC_VECTORS_ERR) \
235240
STATE(IDPF_VC_DEALLOC_VECTORS) \
@@ -259,17 +264,42 @@ enum idpf_vport_vc_state {
259264

260265
extern const char * const idpf_vport_vc_state_str[];
261266

267+
/**
268+
* enum idpf_vport_reset_cause - Vport soft reset causes
269+
* @IDPF_SR_Q_CHANGE: Soft reset queue change
270+
* @IDPF_SR_Q_DESC_CHANGE: Soft reset descriptor change
271+
*/
272+
enum idpf_vport_reset_cause {
273+
IDPF_SR_Q_CHANGE,
274+
IDPF_SR_Q_DESC_CHANGE,
275+
};
276+
262277
/**
263278
* enum idpf_vport_flags - Vport flags
279+
* @IDPF_VPORT_DEL_QUEUES: To send delete queues message
264280
* @IDPF_VPORT_SW_MARKER: Indicate TX pipe drain software marker packets
265281
* processing is done
266282
* @IDPF_VPORT_FLAGS_NBITS: Must be last
267283
*/
268284
enum idpf_vport_flags {
285+
IDPF_VPORT_DEL_QUEUES,
269286
IDPF_VPORT_SW_MARKER,
270287
IDPF_VPORT_FLAGS_NBITS,
271288
};
272289

290+
struct idpf_port_stats {
291+
struct u64_stats_sync stats_sync;
292+
u64_stats_t rx_hw_csum_err;
293+
u64_stats_t rx_hsplit;
294+
u64_stats_t rx_hsplit_hbo;
295+
u64_stats_t rx_bad_descs;
296+
u64_stats_t tx_linearize;
297+
u64_stats_t tx_busy;
298+
u64_stats_t tx_drops;
299+
u64_stats_t tx_dma_map_errs;
300+
struct virtchnl2_vport_stats vport_stats;
301+
};
302+
273303
/**
274304
* struct idpf_vport - Handle for netdevices and queue resources
275305
* @num_txq: Number of allocated TX queues
@@ -311,7 +341,9 @@ enum idpf_vport_flags {
311341
* @default_mac_addr: device will give a default MAC to use
312342
* @rx_itr_profile: RX profiles for Dynamic Interrupt Moderation
313343
* @tx_itr_profile: TX profiles for Dynamic Interrupt Moderation
344+
* @port_stats: per port csum, header split, and other offload stats
314345
* @link_up: True if link is up
346+
* @link_speed_mbps: Link speed in mbps
315347
* @vc_msg: Virtchnl message buffer
316348
* @vc_state: Virtchnl message state
317349
* @vchnl_wq: Wait queue for virtchnl messages
@@ -357,8 +389,10 @@ struct idpf_vport {
357389
u8 default_mac_addr[ETH_ALEN];
358390
u16 rx_itr_profile[IDPF_DIM_PROFILE_SLOTS];
359391
u16 tx_itr_profile[IDPF_DIM_PROFILE_SLOTS];
392+
struct idpf_port_stats port_stats;
360393

361394
bool link_up;
395+
u32 link_speed_mbps;
362396

363397
char vc_msg[IDPF_CTLQ_MAX_BUF_LEN];
364398
DECLARE_BITMAP(vc_state, IDPF_VC_NBITS);
@@ -767,6 +801,17 @@ static inline struct idpf_vport *idpf_netdev_to_vport(struct net_device *netdev)
767801
return np->vport;
768802
}
769803

804+
/**
805+
* idpf_netdev_to_adapter - Get adapter handle from a netdev
806+
* @netdev: Network interface device structure
807+
*/
808+
static inline struct idpf_adapter *idpf_netdev_to_adapter(struct net_device *netdev)
809+
{
810+
struct idpf_netdev_priv *np = netdev_priv(netdev);
811+
812+
return np->adapter;
813+
}
814+
770815
/**
771816
* idpf_is_feature_ena - Determine if a particular feature is enabled
772817
* @vport: Vport to check
@@ -811,6 +856,7 @@ void idpf_mbx_task(struct work_struct *work);
811856
void idpf_vc_event_task(struct work_struct *work);
812857
void idpf_dev_ops_init(struct idpf_adapter *adapter);
813858
void idpf_vf_dev_ops_init(struct idpf_adapter *adapter);
859+
int idpf_vport_adjust_qs(struct idpf_vport *vport);
814860
int idpf_init_dflt_mbx(struct idpf_adapter *adapter);
815861
void idpf_deinit_dflt_mbx(struct idpf_adapter *adapter);
816862
int idpf_vc_core_init(struct idpf_adapter *adapter);
@@ -819,6 +865,11 @@ int idpf_intr_req(struct idpf_adapter *adapter);
819865
void idpf_intr_rel(struct idpf_adapter *adapter);
820866
int idpf_get_reg_intr_vecs(struct idpf_vport *vport,
821867
struct idpf_vec_regs *reg_vals);
868+
int idpf_send_delete_queues_msg(struct idpf_vport *vport);
869+
int idpf_send_add_queues_msg(const struct idpf_vport *vport, u16 num_tx_q,
870+
u16 num_complq, u16 num_rx_q, u16 num_rx_bufq);
871+
int idpf_initiate_soft_reset(struct idpf_vport *vport,
872+
enum idpf_vport_reset_cause reset_cause);
822873
int idpf_send_enable_vport_msg(struct idpf_vport *vport);
823874
int idpf_send_disable_vport_msg(struct idpf_vport *vport);
824875
int idpf_send_destroy_vport_msg(struct idpf_vport *vport);
@@ -831,13 +882,15 @@ void idpf_deinit_task(struct idpf_adapter *adapter);
831882
int idpf_req_rel_vector_indexes(struct idpf_adapter *adapter,
832883
u16 *q_vector_idxs,
833884
struct idpf_vector_info *vec_info);
885+
int idpf_vport_alloc_vec_indexes(struct idpf_vport *vport);
834886
int idpf_get_vec_ids(struct idpf_adapter *adapter,
835887
u16 *vecids, int num_vecids,
836888
struct virtchnl2_vector_chunks *chunks);
837889
int idpf_recv_mb_msg(struct idpf_adapter *adapter, u32 op,
838890
void *msg, int msg_size);
839891
int idpf_send_mb_msg(struct idpf_adapter *adapter, u32 op,
840892
u16 msg_size, u8 *msg);
893+
void idpf_set_ethtool_ops(struct net_device *netdev);
841894
int idpf_vport_alloc_max_qs(struct idpf_adapter *adapter,
842895
struct idpf_vport_max_q *max_q);
843896
void idpf_vport_dealloc_max_qs(struct idpf_adapter *adapter,
@@ -855,6 +908,8 @@ int idpf_send_enable_queues_msg(struct idpf_vport *vport);
855908
int idpf_send_create_vport_msg(struct idpf_adapter *adapter,
856909
struct idpf_vport_max_q *max_q);
857910
int idpf_check_supported_desc_ids(struct idpf_vport *vport);
911+
void idpf_vport_intr_write_itr(struct idpf_q_vector *q_vector,
912+
u16 itr, bool tx);
858913
int idpf_send_map_unmap_queue_vector_msg(struct idpf_vport *vport, bool map);
859914
int idpf_send_set_sriov_vfs_msg(struct idpf_adapter *adapter, u16 num_vfs);
860915
int idpf_sriov_configure(struct pci_dev *pdev, int num_vfs);

0 commit comments

Comments
 (0)