108135eecSEdward Cree /* SPDX-License-Identifier: GPL-2.0-only */ 208135eecSEdward Cree /**************************************************************************** 308135eecSEdward Cree * Driver for Solarflare network controllers and boards 408135eecSEdward Cree * Copyright 2019 Solarflare Communications Inc. 508135eecSEdward Cree * Copyright 2020-2022 Xilinx Inc. 608135eecSEdward Cree * 708135eecSEdward Cree * This program is free software; you can redistribute it and/or modify it 808135eecSEdward Cree * under the terms of the GNU General Public License version 2 as published 908135eecSEdward Cree * by the Free Software Foundation, incorporated herein by reference. 1008135eecSEdward Cree */ 1108135eecSEdward Cree 1208135eecSEdward Cree /* Handling for ef100 representor netdevs */ 1308135eecSEdward Cree #ifndef EF100_REP_H 1408135eecSEdward Cree #define EF100_REP_H 1508135eecSEdward Cree 1608135eecSEdward Cree #include "net_driver.h" 1767ab160eSEdward Cree #include "tc.h" 1808135eecSEdward Cree 1902443ab8SEdward Cree struct efx_rep_sw_stats { 2002443ab8SEdward Cree atomic64_t rx_packets, tx_packets; 2102443ab8SEdward Cree atomic64_t rx_bytes, tx_bytes; 2202443ab8SEdward Cree atomic64_t rx_dropped, tx_errors; 2302443ab8SEdward Cree }; 2402443ab8SEdward Cree 2525414b2aSAlejandro Lucero struct devlink_port; 2625414b2aSAlejandro Lucero 2708135eecSEdward Cree /** 2808135eecSEdward Cree * struct efx_rep - Private data for an Efx representor 2908135eecSEdward Cree * 3008135eecSEdward Cree * @parent: the efx PF which manages this representor 3108135eecSEdward Cree * @net_dev: representor netdevice 3208135eecSEdward Cree * @msg_enable: log message enable flags 33da56552dSEdward Cree * @mport: m-port ID of corresponding VF 34e1479556SEdward Cree * @idx: VF index 3569bb5fa7SEdward Cree * @write_index: number of packets enqueued to @rx_list 3669bb5fa7SEdward Cree * @read_index: number of packets consumed from @rx_list 3769bb5fa7SEdward Cree * @rx_pring_size: max length of RX list 3867ab160eSEdward Cree * @dflt: default-rule for MAE switching 3908135eecSEdward Cree * @list: entry on efx->vf_reps 4069bb5fa7SEdward Cree * @rx_list: list of SKBs queued for receive in NAPI poll 4169bb5fa7SEdward Cree * @rx_lock: protects @rx_list 4269bb5fa7SEdward Cree * @napi: NAPI control structure 4302443ab8SEdward Cree * @stats: software traffic counters for netdev stats 4425414b2aSAlejandro Lucero * @dl_port: devlink port associated to this netdev representor 4508135eecSEdward Cree */ 4608135eecSEdward Cree struct efx_rep { 4708135eecSEdward Cree struct efx_nic *parent; 4808135eecSEdward Cree struct net_device *net_dev; 4908135eecSEdward Cree u32 msg_enable; 50da56552dSEdward Cree u32 mport; 51e1479556SEdward Cree unsigned int idx; 5269bb5fa7SEdward Cree unsigned int write_index, read_index; 5369bb5fa7SEdward Cree unsigned int rx_pring_size; 5467ab160eSEdward Cree struct efx_tc_flow_rule dflt; 5508135eecSEdward Cree struct list_head list; 5669bb5fa7SEdward Cree struct list_head rx_list; 5769bb5fa7SEdward Cree spinlock_t rx_lock; 5869bb5fa7SEdward Cree struct napi_struct napi; 5902443ab8SEdward Cree struct efx_rep_sw_stats stats; 6025414b2aSAlejandro Lucero struct devlink_port *dl_port; 6108135eecSEdward Cree }; 6208135eecSEdward Cree 6308135eecSEdward Cree int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i); 6408135eecSEdward Cree void efx_ef100_vfrep_destroy(struct efx_nic *efx, struct efx_rep *efv); 6508135eecSEdward Cree void efx_ef100_fini_vfreps(struct efx_nic *efx); 6608135eecSEdward Cree 679fe00c80SEdward Cree void efx_ef100_rep_rx_packet(struct efx_rep *efv, struct efx_rx_buffer *rx_buf); 68f50e8fcdSEdward Cree /* Returns the representor corresponding to a VF m-port, or NULL 69f50e8fcdSEdward Cree * @mport is an m-port label, *not* an m-port ID! 70f50e8fcdSEdward Cree * Caller must hold rcu_read_lock(). 71f50e8fcdSEdward Cree */ 72f50e8fcdSEdward Cree struct efx_rep *efx_ef100_find_rep_by_mport(struct efx_nic *efx, u16 mport); 73f54a28a2SEdward Cree extern const struct net_device_ops efx_ef100_rep_netdev_ops; 74a6a15acaSAlejandro Lucero void efx_ef100_init_reps(struct efx_nic *efx); 75a6a15acaSAlejandro Lucero void efx_ef100_fini_reps(struct efx_nic *efx); 7625414b2aSAlejandro Lucero struct mae_mport_desc; 7725414b2aSAlejandro Lucero bool ef100_mport_on_local_intf(struct efx_nic *efx, 7825414b2aSAlejandro Lucero struct mae_mport_desc *mport_desc); 79*fa78b017SAlejandro Lucero bool ef100_mport_is_vf(struct mae_mport_desc *mport_desc); 8008135eecSEdward Cree #endif /* EF100_REP_H */ 81