xref: /linux/Documentation/userspace-api/fwctl/bnxt_fwctl.rst (revision 87fe97a184c000a3941e2b53671742993abb1ddc)
1.. SPDX-License-Identifier: GPL-2.0
2
3=================
4fwctl bnxt driver
5=================
6
7:Author: Pavan Chebbi
8
9Overview
10========
11
12BNXT driver makes a fwctl service available through an auxiliary_device.
13The bnxt_fwctl driver binds to this device and registers itself with the
14fwctl subsystem.
15
16The bnxt_fwctl driver is agnostic to the device firmware internals. It
17uses the Upper Layer Protocol (ULP) conduit provided by bnxt to send
18HardWare Resource Manager (HWRM) commands to firmware.
19
20These commands can query or change firmware driven device configurations
21and read/write registers that are useful for debugging.
22
23bnxt_fwctl User API
24===================
25
26Each RPC request contains the HWRM input structure in the fwctl_rpc
27'in' buffer while 'out' will contain the response.
28
29A typical user application can send a FWCTL_INFO command using ioctl()
30to discover bnxt_fwctl's RPC capabilities as shown below:
31
32        ioctl(fd, FWCTL_INFO, &fwctl_info_msg);
33
34where fwctl_info_msg (of type struct fwctl_info) describes bnxt_info_msg
35(of type struct fwctl_info_bnxt). fwctl_info_msg is set up as follows:
36
37        size = sizeof(struct fwctl_info);
38        flags = 0;
39        device_data_len = sizeof(bnxt_info_msg);
40        out_device_data = (__aligned_u64)&bnxt_info_msg;
41
42The uctx_caps of bnxt_info_msg represents the capabilities as described
43in fwctl_bnxt_commands of include/uapi/fwctl/bnxt.h
44
45The FW RPC itself, FWCTL_RPC can be sent using ioctl() as:
46
47        ioctl(fd, FWCTL_RPC, &fwctl_rpc_msg);
48
49where fwctl_rpc_msg (of type struct fwctl_rpc) carries the HWRM command
50in its 'in' buffer. The HWRM input structures are described in
51include/linux/bnxt/hsi.h. An example for HWRM_VER_GET is shown below:
52
53        struct hwrm_ver_get_output resp;
54        struct fwctl_rpc fwctl_rpc_msg;
55        struct hwrm_ver_get_input req;
56
57        req.req_type = HWRM_VER_GET;
58        req.hwrm_intf_maj = HWRM_VERSION_MAJOR;
59        req.hwrm_intf_min = HWRM_VERSION_MINOR;
60        req.hwrm_intf_upd = HWRM_VERSION_UPDATE;
61        req.cmpl_ring = -1;
62        req.target_id = -1;
63
64        fwctl_rpc_msg.size = sizeof(struct fwctl_rpc);
65        fwctl_rpc_msg.scope = FWCTL_RPC_DEBUG_READ_ONLY;
66        fwctl_rpc_msg.in_len = sizeof(req);
67        fwctl_rpc_msg.out_len = sizeof(resp);
68        fwctl_rpc_msg.in = (__aligned_u64)&req;
69        fwctl_rpc_msg.out = (__aligned_u64)&resp;
70
71An example python3 program that can exercise this interface can be found in
72the following git repository:
73
74https://github.com/Broadcom/fwctl-tools
75