Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
0002 /*
0003  * Copyright(c) 2017 - 2020 Intel Corporation.
0004  */
0005 
0006 #ifndef _HFI1_VNIC_H
0007 #define _HFI1_VNIC_H
0008 #include <rdma/opa_vnic.h>
0009 #include "hfi.h"
0010 #include "sdma.h"
0011 
0012 #define HFI1_VNIC_MAX_TXQ     16
0013 #define HFI1_VNIC_MAX_PAD     12
0014 
0015 /* L4 header definitions */
0016 #define HFI1_VNIC_L4_HDR_OFFSET  OPA_VNIC_L2_HDR_LEN
0017 
0018 #define HFI1_VNIC_GET_L4_HDR(data)   \
0019     (*((u16 *)((u8 *)(data) + HFI1_VNIC_L4_HDR_OFFSET)))
0020 
0021 #define HFI1_VNIC_GET_VESWID(data)   \
0022     (HFI1_VNIC_GET_L4_HDR(data) & 0xFFF)
0023 
0024 /* Service class */
0025 #define HFI1_VNIC_SC_OFFSET_LOW 6
0026 #define HFI1_VNIC_SC_OFFSET_HI  7
0027 #define HFI1_VNIC_SC_SHIFT      4
0028 
0029 #define HFI1_VNIC_MAX_QUEUE 16
0030 #define HFI1_NUM_VNIC_CTXT 8
0031 
0032 /**
0033  * struct hfi1_vnic_sdma - VNIC per Tx ring SDMA information
0034  * @dd - device data pointer
0035  * @sde - sdma engine
0036  * @vinfo - vnic info pointer
0037  * @wait - iowait structure
0038  * @stx - sdma tx request
0039  * @state - vnic Tx ring SDMA state
0040  * @q_idx - vnic Tx queue index
0041  */
0042 struct hfi1_vnic_sdma {
0043     struct hfi1_devdata *dd;
0044     struct sdma_engine  *sde;
0045     struct hfi1_vnic_vport_info *vinfo;
0046     struct iowait wait;
0047     struct sdma_txreq stx;
0048     unsigned int state;
0049     u8 q_idx;
0050     bool pkts_sent;
0051 };
0052 
0053 /**
0054  * struct hfi1_vnic_rx_queue - HFI1 VNIC receive queue
0055  * @idx: queue index
0056  * @vinfo: pointer to vport information
0057  * @netdev: network device
0058  * @napi: netdev napi structure
0059  * @skbq: queue of received socket buffers
0060  */
0061 struct hfi1_vnic_rx_queue {
0062     u8                           idx;
0063     struct hfi1_vnic_vport_info *vinfo;
0064     struct net_device           *netdev;
0065     struct napi_struct           napi;
0066 };
0067 
0068 /**
0069  * struct hfi1_vnic_vport_info - HFI1 VNIC virtual port information
0070  * @dd: device data pointer
0071  * @netdev: net device pointer
0072  * @flags: state flags
0073  * @lock: vport lock
0074  * @num_tx_q: number of transmit queues
0075  * @num_rx_q: number of receive queues
0076  * @vesw_id: virtual switch id
0077  * @rxq: Array of receive queues
0078  * @stats: per queue stats
0079  * @sdma: VNIC SDMA structure per TXQ
0080  */
0081 struct hfi1_vnic_vport_info {
0082     struct hfi1_devdata *dd;
0083     struct net_device   *netdev;
0084     unsigned long        flags;
0085 
0086     /* Lock used around state updates */
0087     struct mutex         lock;
0088 
0089     u8  num_tx_q;
0090     u8  num_rx_q;
0091     u16 vesw_id;
0092     struct hfi1_vnic_rx_queue rxq[HFI1_NUM_VNIC_CTXT];
0093 
0094     struct opa_vnic_stats  stats[HFI1_VNIC_MAX_QUEUE];
0095     struct hfi1_vnic_sdma  sdma[HFI1_VNIC_MAX_TXQ];
0096 };
0097 
0098 #define v_dbg(format, arg...) \
0099     netdev_dbg(vinfo->netdev, format, ## arg)
0100 #define v_err(format, arg...) \
0101     netdev_err(vinfo->netdev, format, ## arg)
0102 #define v_info(format, arg...) \
0103     netdev_info(vinfo->netdev, format, ## arg)
0104 
0105 /* vnic hfi1 internal functions */
0106 void hfi1_vnic_setup(struct hfi1_devdata *dd);
0107 int hfi1_vnic_txreq_init(struct hfi1_devdata *dd);
0108 void hfi1_vnic_txreq_deinit(struct hfi1_devdata *dd);
0109 
0110 void hfi1_vnic_bypass_rcv(struct hfi1_packet *packet);
0111 void hfi1_vnic_sdma_init(struct hfi1_vnic_vport_info *vinfo);
0112 bool hfi1_vnic_sdma_write_avail(struct hfi1_vnic_vport_info *vinfo,
0113                 u8 q_idx);
0114 
0115 /* vnic rdma netdev operations */
0116 struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device,
0117                       u32 port_num,
0118                       enum rdma_netdev_t type,
0119                       const char *name,
0120                       unsigned char name_assign_type,
0121                       void (*setup)(struct net_device *));
0122 int hfi1_vnic_send_dma(struct hfi1_devdata *dd, u8 q_idx,
0123                struct hfi1_vnic_vport_info *vinfo,
0124                struct sk_buff *skb, u64 pbc, u8 plen);
0125 
0126 #endif /* _HFI1_VNIC_H */