Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright(c) 2020 Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #ifndef HFI1_NETDEV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define HFI1_NETDEV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "hfi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/xarray.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * struct hfi1_netdev_rxq - Receive Queue for HFI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * dummy netdev. Both IPoIB and VNIC netdevices will be working on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * top of this device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * @napi: napi object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * @priv: ptr to netdev_priv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * @rcd:  ptr to receive context data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) struct hfi1_netdev_rxq {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	struct napi_struct napi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	struct hfi1_netdev_priv *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	struct hfi1_ctxtdata *rcd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * Number of netdev contexts used. Ensure it is less than or equal to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * max queues supported by VNIC (HFI1_VNIC_MAX_QUEUE).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define HFI1_MAX_NETDEV_CTXTS   8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) /* Number of NETDEV RSM entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define NUM_NETDEV_MAP_ENTRIES HFI1_MAX_NETDEV_CTXTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * struct hfi1_netdev_priv: data required to setup and run HFI netdev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * @dd:		hfi1_devdata
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * @rxq:	pointer to dummy netdev receive queues.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * @num_rx_q:	number of receive queues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * @rmt_index:	first free index in RMT Array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * @msix_start: first free MSI-X interrupt vector.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * @dev_tbl:	netdev table for unique identifier VNIC and IPoIb VLANs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * @enabled:	atomic counter of netdevs enabling receive queues.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  *		When 0 NAPI will be disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * @netdevs:	atomic counter of netdevs using dummy netdev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  *		When 0 receive queues will be freed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) struct hfi1_netdev_priv {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	struct hfi1_devdata *dd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	struct hfi1_netdev_rxq *rxq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	int num_rx_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	int rmt_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	struct xarray dev_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	/* count of enabled napi polls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	atomic_t enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	/* count of netdevs on top */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	atomic_t netdevs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) struct hfi1_netdev_priv *hfi1_netdev_priv(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	return (struct hfi1_netdev_priv *)&dev[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) int hfi1_netdev_ctxt_count(struct hfi1_devdata *dd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct hfi1_netdev_priv *priv = hfi1_netdev_priv(dd->dummy_netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	return priv->num_rx_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) struct hfi1_ctxtdata *hfi1_netdev_get_ctxt(struct hfi1_devdata *dd, int ctxt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	struct hfi1_netdev_priv *priv = hfi1_netdev_priv(dd->dummy_netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	return priv->rxq[ctxt].rcd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) int hfi1_netdev_get_free_rmt_idx(struct hfi1_devdata *dd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	struct hfi1_netdev_priv *priv = hfi1_netdev_priv(dd->dummy_netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	return priv->rmt_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) void hfi1_netdev_set_free_rmt_idx(struct hfi1_devdata *dd, int rmt_idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	struct hfi1_netdev_priv *priv = hfi1_netdev_priv(dd->dummy_netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	priv->rmt_start = rmt_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) u32 hfi1_num_netdev_contexts(struct hfi1_devdata *dd, u32 available_contexts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			     struct cpumask *cpu_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) void hfi1_netdev_enable_queues(struct hfi1_devdata *dd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) void hfi1_netdev_disable_queues(struct hfi1_devdata *dd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) int hfi1_netdev_rx_init(struct hfi1_devdata *dd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int hfi1_netdev_rx_destroy(struct hfi1_devdata *dd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) int hfi1_netdev_alloc(struct hfi1_devdata *dd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) void hfi1_netdev_free(struct hfi1_devdata *dd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int hfi1_netdev_add_data(struct hfi1_devdata *dd, int id, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) void *hfi1_netdev_remove_data(struct hfi1_devdata *dd, int id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) void *hfi1_netdev_get_data(struct hfi1_devdata *dd, int id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) void *hfi1_netdev_get_first_data(struct hfi1_devdata *dd, int *start_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /* chip.c  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int hfi1_netdev_rx_napi(struct napi_struct *napi, int budget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #endif /* HFI1_NETDEV_H */