]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.h
bnxt_en: move HWRM API implementation into separate file
[mirror_ubuntu-jammy-kernel.git] / drivers / net / ethernet / broadcom / bnxt / bnxt_hwrm.h
CommitLineData
3c8c20db
EP
1/* Broadcom NetXtreme-C/E network driver.
2 *
3 * Copyright (c) 2020 Broadcom Limited
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation.
8 */
9
10#ifndef BNXT_HWRM_H
11#define BNXT_HWRM_H
12
13#include "bnxt_hsi.h"
14
15#define BNXT_HWRM_MAX_REQ_LEN (bp->hwrm_max_req_len)
16#define BNXT_HWRM_SHORT_REQ_LEN sizeof(struct hwrm_short_input)
17#define HWRM_CMD_MAX_TIMEOUT 40000
18#define SHORT_HWRM_CMD_TIMEOUT 20
19#define HWRM_CMD_TIMEOUT (bp->hwrm_cmd_timeout)
20#define HWRM_RESET_TIMEOUT ((HWRM_CMD_TIMEOUT) * 4)
21#define HWRM_COREDUMP_TIMEOUT ((HWRM_CMD_TIMEOUT) * 12)
22#define BNXT_HWRM_REQ_MAX_SIZE 128
23#define BNXT_HWRM_REQS_PER_PAGE (BNXT_PAGE_SIZE / \
24 BNXT_HWRM_REQ_MAX_SIZE)
25#define HWRM_SHORT_MIN_TIMEOUT 3
26#define HWRM_SHORT_MAX_TIMEOUT 10
27#define HWRM_SHORT_TIMEOUT_COUNTER 5
28
29#define HWRM_MIN_TIMEOUT 25
30#define HWRM_MAX_TIMEOUT 40
31
32#define HWRM_WAIT_MUST_ABORT(bp, req) \
33 (le16_to_cpu((req)->req_type) != HWRM_VER_GET && \
34 !bnxt_is_fw_healthy(bp))
35
36#define HWRM_TOTAL_TIMEOUT(n) (((n) <= HWRM_SHORT_TIMEOUT_COUNTER) ? \
37 ((n) * HWRM_SHORT_MIN_TIMEOUT) : \
38 (HWRM_SHORT_TIMEOUT_COUNTER * HWRM_SHORT_MIN_TIMEOUT + \
39 ((n) - HWRM_SHORT_TIMEOUT_COUNTER) * HWRM_MIN_TIMEOUT))
40
41#define HWRM_VALID_BIT_DELAY_USEC 150
42
43#define BNXT_HWRM_CHNL_CHIMP 0
44#define BNXT_HWRM_CHNL_KONG 1
45
46static inline bool bnxt_cfa_hwrm_message(u16 req_type)
47{
48 switch (req_type) {
49 case HWRM_CFA_ENCAP_RECORD_ALLOC:
50 case HWRM_CFA_ENCAP_RECORD_FREE:
51 case HWRM_CFA_DECAP_FILTER_ALLOC:
52 case HWRM_CFA_DECAP_FILTER_FREE:
53 case HWRM_CFA_EM_FLOW_ALLOC:
54 case HWRM_CFA_EM_FLOW_FREE:
55 case HWRM_CFA_EM_FLOW_CFG:
56 case HWRM_CFA_FLOW_ALLOC:
57 case HWRM_CFA_FLOW_FREE:
58 case HWRM_CFA_FLOW_INFO:
59 case HWRM_CFA_FLOW_FLUSH:
60 case HWRM_CFA_FLOW_STATS:
61 case HWRM_CFA_METER_PROFILE_ALLOC:
62 case HWRM_CFA_METER_PROFILE_FREE:
63 case HWRM_CFA_METER_PROFILE_CFG:
64 case HWRM_CFA_METER_INSTANCE_ALLOC:
65 case HWRM_CFA_METER_INSTANCE_FREE:
66 return true;
67 default:
68 return false;
69 }
70}
71
72static inline bool bnxt_kong_hwrm_message(struct bnxt *bp, struct input *req)
73{
74 return (bp->fw_cap & BNXT_FW_CAP_KONG_MB_CHNL &&
75 (bnxt_cfa_hwrm_message(le16_to_cpu(req->req_type)) ||
76 le16_to_cpu(req->target_id) == HWRM_TARGET_ID_KONG));
77}
78
79static inline void *bnxt_get_hwrm_resp_addr(struct bnxt *bp, void *req)
80{
81 return bp->hwrm_cmd_resp_addr;
82}
83
84static inline u16 bnxt_get_hwrm_seq_id(struct bnxt *bp, u16 dst)
85{
86 u16 seq_id;
87
88 if (dst == BNXT_HWRM_CHNL_CHIMP)
89 seq_id = bp->hwrm_cmd_seq++;
90 else
91 seq_id = bp->hwrm_cmd_kong_seq++;
92 return seq_id;
93}
94
95void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16);
96int _hwrm_send_message(struct bnxt *bp, void *msg, u32 len, int timeout);
97int _hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 len, int timeout);
98int hwrm_send_message(struct bnxt *bp, void *msg, u32 len, int timeout);
99int hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 len, int timeout);
100#endif