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