Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
0002 /*
0003  * Copyright(c) 2020 Intel Corporation.
0004  *
0005  */
0006 
0007 /*
0008  * This file contains HFI1 support for IPOIB functionality
0009  */
0010 
0011 #ifndef HFI1_IPOIB_H
0012 #define HFI1_IPOIB_H
0013 
0014 #include <linux/types.h>
0015 #include <linux/stddef.h>
0016 #include <linux/atomic.h>
0017 #include <linux/netdevice.h>
0018 #include <linux/slab.h>
0019 #include <linux/skbuff.h>
0020 #include <linux/list.h>
0021 #include <linux/if_infiniband.h>
0022 
0023 #include "hfi.h"
0024 #include "iowait.h"
0025 #include "netdev.h"
0026 
0027 #include <rdma/ib_verbs.h>
0028 
0029 #define HFI1_IPOIB_ENTROPY_SHIFT   24
0030 
0031 #define HFI1_IPOIB_TXREQ_NAME_LEN   32
0032 
0033 #define HFI1_IPOIB_PSEUDO_LEN 20
0034 #define HFI1_IPOIB_ENCAP_LEN 4
0035 
0036 struct hfi1_ipoib_dev_priv;
0037 
0038 union hfi1_ipoib_flow {
0039     u16 as_int;
0040     struct {
0041         u8 tx_queue;
0042         u8 sc5;
0043     } __attribute__((__packed__));
0044 };
0045 
0046 /**
0047  * struct ipoib_txreq - IPOIB transmit descriptor
0048  * @txreq: sdma transmit request
0049  * @sdma_hdr: 9b ib headers
0050  * @sdma_status: status returned by sdma engine
0051  * @complete: non-zero implies complete
0052  * @priv: ipoib netdev private data
0053  * @txq: txq on which skb was output
0054  * @skb: skb to send
0055  */
0056 struct ipoib_txreq {
0057     struct sdma_txreq           txreq;
0058     struct hfi1_sdma_header     *sdma_hdr;
0059     int                         sdma_status;
0060     int                         complete;
0061     struct hfi1_ipoib_dev_priv *priv;
0062     struct hfi1_ipoib_txq      *txq;
0063     struct sk_buff             *skb;
0064 };
0065 
0066 /**
0067  * struct hfi1_ipoib_circ_buf - List of items to be processed
0068  * @items: ring of items each a power of two size
0069  * @max_items: max items + 1 that the ring can contain
0070  * @shift: log2 of size for getting txreq
0071  * @sent_txreqs: count of txreqs posted to sdma
0072  * @tail: ring tail
0073  * @stops: count of stops of queue
0074  * @ring_full: ring has been filled
0075  * @no_desc: descriptor shortage seen
0076  * @complete_txreqs: count of txreqs completed by sdma
0077  * @head: ring head
0078  */
0079 struct hfi1_ipoib_circ_buf {
0080     void *items;
0081     u32 max_items;
0082     u32 shift;
0083     /* consumer cache line */
0084     u64 ____cacheline_aligned_in_smp sent_txreqs;
0085     u32 avail;
0086     u32 tail;
0087     atomic_t stops;
0088     atomic_t ring_full;
0089     atomic_t no_desc;
0090     /* producer cache line */
0091     u64 ____cacheline_aligned_in_smp complete_txreqs;
0092     u32 head;
0093 };
0094 
0095 /**
0096  * struct hfi1_ipoib_txq - IPOIB per Tx queue information
0097  * @priv: private pointer
0098  * @sde: sdma engine
0099  * @tx_list: tx request list
0100  * @sent_txreqs: count of txreqs posted to sdma
0101  * @flow: tracks when list needs to be flushed for a flow change
0102  * @q_idx: ipoib Tx queue index
0103  * @pkts_sent: indicator packets have been sent from this queue
0104  * @wait: iowait structure
0105  * @napi: pointer to tx napi interface
0106  * @tx_ring: ring of ipoib txreqs to be reaped by napi callback
0107  */
0108 struct hfi1_ipoib_txq {
0109     struct napi_struct napi;
0110     struct hfi1_ipoib_dev_priv *priv;
0111     struct sdma_engine *sde;
0112     struct list_head tx_list;
0113     union hfi1_ipoib_flow flow;
0114     u8 q_idx;
0115     bool pkts_sent;
0116     struct iowait wait;
0117 
0118     struct hfi1_ipoib_circ_buf ____cacheline_aligned_in_smp tx_ring;
0119 };
0120 
0121 struct hfi1_ipoib_dev_priv {
0122     struct hfi1_devdata *dd;
0123     struct net_device   *netdev;
0124     struct ib_device    *device;
0125     struct hfi1_ipoib_txq *txqs;
0126     const struct net_device_ops *netdev_ops;
0127     struct rvt_qp *qp;
0128     u32 qkey;
0129     u16 pkey;
0130     u16 pkey_index;
0131     u8 port_num;
0132 };
0133 
0134 /* hfi1 ipoib rdma netdev's private data structure */
0135 struct hfi1_ipoib_rdma_netdev {
0136     struct rdma_netdev rn;  /* keep this first */
0137     /* followed by device private data */
0138     struct hfi1_ipoib_dev_priv dev_priv;
0139 };
0140 
0141 static inline struct hfi1_ipoib_dev_priv *
0142 hfi1_ipoib_priv(const struct net_device *dev)
0143 {
0144     return &((struct hfi1_ipoib_rdma_netdev *)netdev_priv(dev))->dev_priv;
0145 }
0146 
0147 int hfi1_ipoib_send(struct net_device *dev,
0148             struct sk_buff *skb,
0149             struct ib_ah *address,
0150             u32 dqpn);
0151 
0152 int hfi1_ipoib_txreq_init(struct hfi1_ipoib_dev_priv *priv);
0153 void hfi1_ipoib_txreq_deinit(struct hfi1_ipoib_dev_priv *priv);
0154 
0155 int hfi1_ipoib_rxq_init(struct net_device *dev);
0156 void hfi1_ipoib_rxq_deinit(struct net_device *dev);
0157 
0158 void hfi1_ipoib_napi_tx_enable(struct net_device *dev);
0159 void hfi1_ipoib_napi_tx_disable(struct net_device *dev);
0160 
0161 struct sk_buff *hfi1_ipoib_prepare_skb(struct hfi1_netdev_rxq *rxq,
0162                        int size, void *data);
0163 
0164 int hfi1_ipoib_rn_get_params(struct ib_device *device,
0165                  u32 port_num,
0166                  enum rdma_netdev_t type,
0167                  struct rdma_netdev_alloc_params *params);
0168 
0169 void hfi1_ipoib_tx_timeout(struct net_device *dev, unsigned int q);
0170 
0171 #endif /* _IPOIB_H */