1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /****************************************************************************
3  * Driver for Solarflare network controllers and boards
4  * Copyright 2019 Solarflare Communications Inc.
5  * Copyright 2020-2022 Xilinx Inc.
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License version 2 as published
9  * by the Free Software Foundation, incorporated herein by reference.
10  */
11 
12 /* Handling for ef100 representor netdevs */
13 #ifndef EF100_REP_H
14 #define EF100_REP_H
15 
16 #include "net_driver.h"
17 #include "tc.h"
18 
19 struct efx_rep_sw_stats {
20 	atomic64_t rx_packets, tx_packets;
21 	atomic64_t rx_bytes, tx_bytes;
22 	atomic64_t rx_dropped, tx_errors;
23 };
24 
25 /**
26  * struct efx_rep - Private data for an Efx representor
27  *
28  * @parent: the efx PF which manages this representor
29  * @net_dev: representor netdevice
30  * @msg_enable: log message enable flags
31  * @mport: m-port ID of corresponding VF
32  * @idx: VF index
33  * @write_index: number of packets enqueued to @rx_list
34  * @read_index: number of packets consumed from @rx_list
35  * @rx_pring_size: max length of RX list
36  * @dflt: default-rule for MAE switching
37  * @list: entry on efx->vf_reps
38  * @rx_list: list of SKBs queued for receive in NAPI poll
39  * @rx_lock: protects @rx_list
40  * @napi: NAPI control structure
41  * @stats: software traffic counters for netdev stats
42  */
43 struct efx_rep {
44 	struct efx_nic *parent;
45 	struct net_device *net_dev;
46 	u32 msg_enable;
47 	u32 mport;
48 	unsigned int idx;
49 	unsigned int write_index, read_index;
50 	unsigned int rx_pring_size;
51 	struct efx_tc_flow_rule dflt;
52 	struct list_head list;
53 	struct list_head rx_list;
54 	spinlock_t rx_lock;
55 	struct napi_struct napi;
56 	struct efx_rep_sw_stats stats;
57 };
58 
59 int efx_ef100_vfrep_create(struct efx_nic *efx, unsigned int i);
60 void efx_ef100_vfrep_destroy(struct efx_nic *efx, struct efx_rep *efv);
61 void efx_ef100_fini_vfreps(struct efx_nic *efx);
62 
63 void efx_ef100_rep_rx_packet(struct efx_rep *efv, struct efx_rx_buffer *rx_buf);
64 /* Returns the representor corresponding to a VF m-port, or NULL
65  * @mport is an m-port label, *not* an m-port ID!
66  * Caller must hold rcu_read_lock().
67  */
68 struct efx_rep *efx_ef100_find_rep_by_mport(struct efx_nic *efx, u16 mport);
69 #endif /* EF100_REP_H */
70