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