1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2021, Intel Corporation. */
3 
4 /* Inter-Driver Communication */
5 #include "ice.h"
6 #include "ice_lib.h"
7 #include "ice_dcb_lib.h"
8 
9 /**
10  * ice_reserve_rdma_qvector - Reserve vector resources for RDMA driver
11  * @pf: board private structure to initialize
12  */
13 static int ice_reserve_rdma_qvector(struct ice_pf *pf)
14 {
15 	if (test_bit(ICE_FLAG_RDMA_ENA, pf->flags)) {
16 		int index;
17 
18 		index = ice_get_res(pf, pf->irq_tracker, pf->num_rdma_msix,
19 				    ICE_RES_RDMA_VEC_ID);
20 		if (index < 0)
21 			return index;
22 		pf->num_avail_sw_msix -= pf->num_rdma_msix;
23 		pf->rdma_base_vector = (u16)index;
24 	}
25 	return 0;
26 }
27 
28 /**
29  * ice_init_rdma - initializes PF for RDMA use
30  * @pf: ptr to ice_pf
31  */
32 int ice_init_rdma(struct ice_pf *pf)
33 {
34 	struct device *dev = &pf->pdev->dev;
35 	int ret;
36 
37 	/* Reserve vector resources */
38 	ret = ice_reserve_rdma_qvector(pf);
39 	if (ret < 0)
40 		dev_err(dev, "failed to reserve vectors for RDMA\n");
41 
42 	return ret;
43 }
44