1 /* 2 * Copyright (c) 2018-2019 Cavium, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * POSSIBILITY OF SUCH DAMAGE. 26 * 27 * $FreeBSD$ 28 */ 29 30 #ifndef __QLNXR_CM_H__ 31 #define __QLNXR_CM_H__ 32 33 /* ECORE LL2 has a limit to the number of buffers it can handle. 34 * FYI, OFED used 512 and 128 for recv and send. 35 */ 36 #define QLNXR_GSI_MAX_RECV_WR (4096) 37 #define QLNXR_GSI_MAX_SEND_WR (4096) 38 39 #define QLNXR_GSI_MAX_RECV_SGE (1) /* LL2 FW limitation */ 40 41 /* future OFED/kernel will have these */ 42 #define ETH_P_ROCE (0x8915) 43 #define QLNXR_ROCE_V2_UDP_SPORT (0000) 44 45 #define rdma_wr(_wr) rdma_wr(_wr) 46 #define ud_wr(_wr) ud_wr(_wr) 47 #define atomic_wr(_wr) atomic_wr(_wr) 48 49 static inline u32 qlnxr_get_ipv4_from_gid(u8 *gid) 50 { 51 return *(u32 *)(void *)&gid[12]; 52 } 53 54 struct ecore_roce_ll2_header { 55 void *vaddr; 56 dma_addr_t baddr; 57 size_t len; 58 }; 59 60 struct ecore_roce_ll2_buffer { 61 dma_addr_t baddr; 62 size_t len; 63 }; 64 65 struct ecore_roce_ll2_packet { 66 struct ecore_roce_ll2_header header; 67 int n_seg; 68 struct ecore_roce_ll2_buffer payload[RDMA_MAX_SGE_PER_SQ_WQE]; 69 int roce_mode; 70 enum ecore_roce_ll2_tx_dest tx_dest; 71 }; 72 73 /* RDMA CM */ 74 75 extern int qlnxr_gsi_poll_cq(struct ib_cq *ibcq, 76 int num_entries, 77 struct ib_wc *wc); 78 79 extern int qlnxr_gsi_post_recv(struct ib_qp *ibqp, 80 const struct ib_recv_wr *wr, 81 const struct ib_recv_wr **bad_wr); 82 83 extern int qlnxr_gsi_post_send(struct ib_qp *ibqp, 84 const struct ib_send_wr *wr, 85 const struct ib_send_wr **bad_wr); 86 87 extern struct ib_qp* qlnxr_create_gsi_qp(struct qlnxr_dev *dev, 88 struct ib_qp_init_attr *attrs, 89 struct qlnxr_qp *qp); 90 91 extern void qlnxr_store_gsi_qp_cq(struct qlnxr_dev *dev, 92 struct qlnxr_qp *qp, 93 struct ib_qp_init_attr *attrs); 94 95 extern void qlnxr_inc_sw_gsi_cons(struct qlnxr_qp_hwq_info *info); 96 97 extern int qlnxr_destroy_gsi_qp(struct qlnxr_dev *dev); 98 99 #endif /* #ifndef __QLNXR_CM_H__ */ 100