summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/meta/mpnic/mpnic_netdev.h
blob: 6711766ebc3c5266e139bb22fdf62dbdbd2157c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) Meta Platforms, Inc. and affiliates. */

#ifndef _MPNIC_NETDEV_H_
#define _MPNIC_NETDEV_H_

#include <linux/netdevice.h>
#include <linux/rcupdate.h>
#include <linux/types.h>

#include "mpnic.h"
#include "mpnic_txrx.h"

struct mpnic_base_stats {
	struct {
		u64 packets;
		u64 bytes;
		u64 dropped;
		u64 stop;
		u64 wake;
	} tx;
	struct {
		u64 packets;
		u64 bytes;
		u64 dropped;
		u64 alloc_failed;
		u64 errors;
	} rx;

	unsigned int num_tx_queues;
	unsigned int num_rx_queues;
	struct mpnic_ring **txr;
	struct mpnic_ring **rxr;
};

struct mpnic_net {
	struct mpnic_ring *tx[MPNIC_MAX_TXQS];
	struct mpnic_ring *rx[MPNIC_MAX_RXQS];

	struct mpnic_napi_vector *napi[MPNIC_MAX_NAPI_VECTORS];

	struct net_device *netdev;
	struct mpnic_dev *mpd;

	u32 txq_size;
	u32 hpq_size;
	u32 ppq_size;
	u32 rcq_size;

	u16 num_napi;
	u16 num_tx_queues;
	u16 num_rx_queues;

	struct {
		struct mpnic_base_stats __rcu *base;
		struct mpnic_base_stats buf[2];
	} stats;
};

struct net_device *mpnic_netdev_alloc(struct mpnic_dev *mpd);
void mpnic_netdev_free(struct mpnic_dev *mpd);
int mpnic_netdev_register(struct net_device *netdev);

#endif /* _MPNIC_NETDEV_H_ */