net/bnxt: add initial TruFlow core session open
[dpdk.git] / drivers / net / bnxt / tf_core / tf_msg.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #include <inttypes.h>
7 #include <stdbool.h>
8 #include <stdlib.h>
9
10 #include "bnxt.h"
11 #include "tf_core.h"
12 #include "tf_session.h"
13 #include "tfp.h"
14
15 #include "tf_msg_common.h"
16 #include "tf_msg.h"
17 #include "hsi_struct_def_dpdk.h"
18 #include "hwrm_tf.h"
19
20 /**
21  * Sends session open request to TF Firmware
22  */
23 int
24 tf_msg_session_open(struct tf *tfp,
25                     char *ctrl_chan_name,
26                     uint8_t *fw_session_id)
27 {
28         int rc;
29         struct hwrm_tf_session_open_input req = { 0 };
30         struct hwrm_tf_session_open_output resp = { 0 };
31         struct tfp_send_msg_parms parms = { 0 };
32
33         /* Populate the request */
34         memcpy(&req.session_name, ctrl_chan_name, TF_SESSION_NAME_MAX);
35
36         parms.tf_type = HWRM_TF_SESSION_OPEN;
37         parms.req_data = (uint32_t *)&req;
38         parms.req_size = sizeof(req);
39         parms.resp_data = (uint32_t *)&resp;
40         parms.resp_size = sizeof(resp);
41         parms.mailbox = TF_KONG_MB;
42
43         rc = tfp_send_msg_direct(tfp,
44                                  &parms);
45         if (rc)
46                 return rc;
47
48         *fw_session_id = resp.fw_session_id;
49
50         return rc;
51 }
52
53 /**
54  * Sends session query config request to TF Firmware
55  */
56 int
57 tf_msg_session_qcfg(struct tf *tfp)
58 {
59         int rc;
60         struct hwrm_tf_session_qcfg_input  req = { 0 };
61         struct hwrm_tf_session_qcfg_output resp = { 0 };
62         struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);
63         struct tfp_send_msg_parms parms = { 0 };
64
65         /* Populate the request */
66         req.fw_session_id =
67                 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
68
69         parms.tf_type = HWRM_TF_SESSION_QCFG,
70         parms.req_data = (uint32_t *)&req;
71         parms.req_size = sizeof(req);
72         parms.resp_data = (uint32_t *)&resp;
73         parms.resp_size = sizeof(resp);
74         parms.mailbox = TF_KONG_MB;
75
76         rc = tfp_send_msg_direct(tfp,
77                                  &parms);
78         return rc;
79 }