0001
0002
0003
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
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
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
0034
0035
0036
0037
0038
0039
0040
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
0055
0056
0057
0058
0059
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
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 struct hfi1_vnic_vport_info {
0082 struct hfi1_devdata *dd;
0083 struct net_device *netdev;
0084 unsigned long flags;
0085
0086
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
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
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