Skip to content

Commit 8f5ee3c

Browse files
jacob-kelleranguy11
authored andcommitted
ice: add support for sideband messages
In order to support certain device features, including enabling the PTP hardware clock, the ice driver needs to control some registers on the device PHY. These registers are accessed by sending sideband messages. For some hardware, these messages must be sent over the device admin queue, while other hardware has a dedicated control queue for the sideband messages. Add the neighbor device message structure for sending a message to the neighboring device. Where supported, initialize the sideband control queue and handle cleanup. Add a wrapper function for sending sideband control queue messages that read or write a neighboring device register. Because some devices send sideband messages over the AdminQ, also increase the length of the admin queue to allow more messages to be queued up. This is important because the sideband messages add additional pressure on the AQ usage. This support will be used in following patches to enable support for CONFIG_1588_PTP_CLOCK. Signed-off-by: Jacob Keller <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 76cf404 commit 8f5ee3c

File tree

11 files changed

+343
-2
lines changed

11 files changed

+343
-2
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@
7474

7575
#define ICE_DFLT_TRAFFIC_CLASS BIT(0)
7676
#define ICE_INT_NAME_STR_LEN (IFNAMSIZ + 16)
77-
#define ICE_AQ_LEN 64
77+
#define ICE_AQ_LEN 192
7878
#define ICE_MBXSQ_LEN 64
79+
#define ICE_SBQ_LEN 64
7980
#define ICE_MIN_LAN_TXRX_MSIX 1
8081
#define ICE_MIN_LAN_OICR_MSIX 1
8182
#define ICE_MIN_MSIX (ICE_MIN_LAN_TXRX_MSIX + ICE_MIN_LAN_OICR_MSIX)
@@ -227,6 +228,7 @@ enum ice_pf_state {
227228
ICE_STATE_NOMINAL_CHECK_BITS,
228229
ICE_ADMINQ_EVENT_PENDING,
229230
ICE_MAILBOXQ_EVENT_PENDING,
231+
ICE_SIDEBANDQ_EVENT_PENDING,
230232
ICE_MDD_EVENT_PENDING,
231233
ICE_VFLR_EVENT_PENDING,
232234
ICE_FLTR_OVERFLOW_PROMISC,

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,15 @@ struct ice_aqc_get_set_rss_lut {
16111611
__le32 addr_low;
16121612
};
16131613

1614+
/* Sideband Control Interface Commands */
1615+
/* Neighbor Device Request (indirect 0x0C00); also used for the response. */
1616+
struct ice_aqc_neigh_dev_req {
1617+
__le16 sb_data_len;
1618+
u8 reserved[6];
1619+
__le32 addr_high;
1620+
__le32 addr_low;
1621+
};
1622+
16141623
/* Add Tx LAN Queues (indirect 0x0C30) */
16151624
struct ice_aqc_add_txqs {
16161625
u8 num_qgrps;
@@ -1911,6 +1920,7 @@ struct ice_aq_desc {
19111920
struct ice_aqc_lldp_filter_ctrl lldp_filter_ctrl;
19121921
struct ice_aqc_get_set_rss_lut get_set_rss_lut;
19131922
struct ice_aqc_get_set_rss_key get_set_rss_key;
1923+
struct ice_aqc_neigh_dev_req neigh_dev;
19141924
struct ice_aqc_add_txqs add_txqs;
19151925
struct ice_aqc_dis_txqs dis_txqs;
19161926
struct ice_aqc_add_rdma_qset add_rdma_qset;
@@ -2059,6 +2069,9 @@ enum ice_adminq_opc {
20592069
ice_aqc_opc_get_rss_key = 0x0B04,
20602070
ice_aqc_opc_get_rss_lut = 0x0B05,
20612071

2072+
/* Sideband Control Interface commands */
2073+
ice_aqc_opc_neighbour_device_request = 0x0C00,
2074+
20622075
/* Tx queue handling commands/events */
20632076
ice_aqc_opc_add_txqs = 0x0C30,
20642077
ice_aqc_opc_dis_txqs = 0x0C31,

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,64 @@ const struct ice_ctx_ele ice_tlan_ctx_info[] = {
12931293
{ 0 }
12941294
};
12951295

1296+
/* Sideband Queue command wrappers */
1297+
1298+
/**
1299+
* ice_sbq_send_cmd - send Sideband Queue command to Sideband Queue
1300+
* @hw: pointer to the HW struct
1301+
* @desc: descriptor describing the command
1302+
* @buf: buffer to use for indirect commands (NULL for direct commands)
1303+
* @buf_size: size of buffer for indirect commands (0 for direct commands)
1304+
* @cd: pointer to command details structure
1305+
*/
1306+
static int
1307+
ice_sbq_send_cmd(struct ice_hw *hw, struct ice_sbq_cmd_desc *desc,
1308+
void *buf, u16 buf_size, struct ice_sq_cd *cd)
1309+
{
1310+
return ice_status_to_errno(ice_sq_send_cmd(hw, ice_get_sbq(hw),
1311+
(struct ice_aq_desc *)desc,
1312+
buf, buf_size, cd));
1313+
}
1314+
1315+
/**
1316+
* ice_sbq_rw_reg - Fill Sideband Queue command
1317+
* @hw: pointer to the HW struct
1318+
* @in: message info to be filled in descriptor
1319+
*/
1320+
int ice_sbq_rw_reg(struct ice_hw *hw, struct ice_sbq_msg_input *in)
1321+
{
1322+
struct ice_sbq_cmd_desc desc = {0};
1323+
struct ice_sbq_msg_req msg = {0};
1324+
u16 msg_len;
1325+
int status;
1326+
1327+
msg_len = sizeof(msg);
1328+
1329+
msg.dest_dev = in->dest_dev;
1330+
msg.opcode = in->opcode;
1331+
msg.flags = ICE_SBQ_MSG_FLAGS;
1332+
msg.sbe_fbe = ICE_SBQ_MSG_SBE_FBE;
1333+
msg.msg_addr_low = cpu_to_le16(in->msg_addr_low);
1334+
msg.msg_addr_high = cpu_to_le32(in->msg_addr_high);
1335+
1336+
if (in->opcode)
1337+
msg.data = cpu_to_le32(in->data);
1338+
else
1339+
/* data read comes back in completion, so shorten the struct by
1340+
* sizeof(msg.data)
1341+
*/
1342+
msg_len -= sizeof(msg.data);
1343+
1344+
desc.flags = cpu_to_le16(ICE_AQ_FLAG_RD);
1345+
desc.opcode = cpu_to_le16(ice_sbq_opc_neigh_dev_req);
1346+
desc.param0.cmd_len = cpu_to_le16(msg_len);
1347+
status = ice_sbq_send_cmd(hw, &desc, &msg, msg_len, NULL);
1348+
if (!status && !in->opcode)
1349+
in->data = le32_to_cpu
1350+
(((struct ice_sbq_msg_cmpl *)&msg)->data);
1351+
return status;
1352+
}
1353+
12961354
/* FW Admin Queue command wrappers */
12971355

12981356
/* Software lock/mutex that is meant to be held while the Global Config Lock

drivers/net/ethernet/intel/ice/ice_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ enum ice_status
4040
ice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries,
4141
struct ice_aqc_alloc_free_res_elem *buf, u16 buf_size,
4242
enum ice_adminq_opc opc, struct ice_sq_cd *cd);
43+
bool ice_is_sbq_supported(struct ice_hw *hw);
44+
struct ice_ctl_q_info *ice_get_sbq(struct ice_hw *hw);
4345
enum ice_status
4446
ice_sq_send_cmd(struct ice_hw *hw, struct ice_ctl_q_info *cq,
4547
struct ice_aq_desc *desc, void *buf, u16 buf_size,
@@ -173,6 +175,7 @@ void ice_replay_post(struct ice_hw *hw);
173175
void ice_output_fw_log(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf);
174176
struct ice_q_ctx *
175177
ice_get_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 q_handle);
178+
int ice_sbq_rw_reg(struct ice_hw *hw, struct ice_sbq_msg_input *in);
176179
void
177180
ice_stat_update40(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
178181
u64 *prev_stat, u64 *cur_stat);

drivers/net/ethernet/intel/ice/ice_controlq.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ static void ice_mailbox_init_regs(struct ice_hw *hw)
5151
ICE_CQ_INIT_REGS(cq, PF_MBX);
5252
}
5353

54+
/**
55+
* ice_sb_init_regs - Initialize Sideband registers
56+
* @hw: pointer to the hardware structure
57+
*
58+
* This assumes the alloc_sq and alloc_rq functions have already been called
59+
*/
60+
static void ice_sb_init_regs(struct ice_hw *hw)
61+
{
62+
struct ice_ctl_q_info *cq = &hw->sbq;
63+
64+
ICE_CQ_INIT_REGS(cq, PF_SB);
65+
}
66+
5467
/**
5568
* ice_check_sq_alive
5669
* @hw: pointer to the HW struct
@@ -609,6 +622,10 @@ static enum ice_status ice_init_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type)
609622
ice_adminq_init_regs(hw);
610623
cq = &hw->adminq;
611624
break;
625+
case ICE_CTL_Q_SB:
626+
ice_sb_init_regs(hw);
627+
cq = &hw->sbq;
628+
break;
612629
case ICE_CTL_Q_MAILBOX:
613630
ice_mailbox_init_regs(hw);
614631
cq = &hw->mailboxq;
@@ -645,6 +662,32 @@ static enum ice_status ice_init_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type)
645662
return ret_code;
646663
}
647664

665+
/**
666+
* ice_is_sbq_supported - is the sideband queue supported
667+
* @hw: pointer to the hardware structure
668+
*
669+
* Returns true if the sideband control queue interface is
670+
* supported for the device, false otherwise
671+
*/
672+
bool ice_is_sbq_supported(struct ice_hw *hw)
673+
{
674+
/* The device sideband queue is only supported on devices with the
675+
* generic MAC type.
676+
*/
677+
return hw->mac_type == ICE_MAC_GENERIC;
678+
}
679+
680+
/**
681+
* ice_get_sbq - returns the right control queue to use for sideband
682+
* @hw: pointer to the hardware structure
683+
*/
684+
struct ice_ctl_q_info *ice_get_sbq(struct ice_hw *hw)
685+
{
686+
if (ice_is_sbq_supported(hw))
687+
return &hw->sbq;
688+
return &hw->adminq;
689+
}
690+
648691
/**
649692
* ice_shutdown_ctrlq - shutdown routine for any control queue
650693
* @hw: pointer to the hardware structure
@@ -662,6 +705,9 @@ static void ice_shutdown_ctrlq(struct ice_hw *hw, enum ice_ctl_q q_type)
662705
if (ice_check_sq_alive(hw, cq))
663706
ice_aq_q_shutdown(hw, true);
664707
break;
708+
case ICE_CTL_Q_SB:
709+
cq = &hw->sbq;
710+
break;
665711
case ICE_CTL_Q_MAILBOX:
666712
cq = &hw->mailboxq;
667713
break;
@@ -685,6 +731,9 @@ void ice_shutdown_all_ctrlq(struct ice_hw *hw)
685731
{
686732
/* Shutdown FW admin queue */
687733
ice_shutdown_ctrlq(hw, ICE_CTL_Q_ADMIN);
734+
/* Shutdown PHY Sideband */
735+
if (ice_is_sbq_supported(hw))
736+
ice_shutdown_ctrlq(hw, ICE_CTL_Q_SB);
688737
/* Shutdown PF-VF Mailbox */
689738
ice_shutdown_ctrlq(hw, ICE_CTL_Q_MAILBOX);
690739
}
@@ -724,6 +773,15 @@ enum ice_status ice_init_all_ctrlq(struct ice_hw *hw)
724773

725774
if (status)
726775
return status;
776+
/* sideband control queue (SBQ) interface is not supported on some
777+
* devices. Initialize if supported, else fallback to the admin queue
778+
* interface
779+
*/
780+
if (ice_is_sbq_supported(hw)) {
781+
status = ice_init_ctrlq(hw, ICE_CTL_Q_SB);
782+
if (status)
783+
return status;
784+
}
727785
/* Init Mailbox queue */
728786
return ice_init_ctrlq(hw, ICE_CTL_Q_MAILBOX);
729787
}
@@ -759,6 +817,8 @@ static void ice_init_ctrlq_locks(struct ice_ctl_q_info *cq)
759817
enum ice_status ice_create_all_ctrlq(struct ice_hw *hw)
760818
{
761819
ice_init_ctrlq_locks(&hw->adminq);
820+
if (ice_is_sbq_supported(hw))
821+
ice_init_ctrlq_locks(&hw->sbq);
762822
ice_init_ctrlq_locks(&hw->mailboxq);
763823

764824
return ice_init_all_ctrlq(hw);
@@ -791,6 +851,8 @@ void ice_destroy_all_ctrlq(struct ice_hw *hw)
791851
ice_shutdown_all_ctrlq(hw);
792852

793853
ice_destroy_ctrlq_locks(&hw->adminq);
854+
if (ice_is_sbq_supported(hw))
855+
ice_destroy_ctrlq_locks(&hw->sbq);
794856
ice_destroy_ctrlq_locks(&hw->mailboxq);
795857
}
796858

drivers/net/ethernet/intel/ice/ice_controlq.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/* Maximum buffer lengths for all control queue types */
1010
#define ICE_AQ_MAX_BUF_LEN 4096
1111
#define ICE_MBXQ_MAX_BUF_LEN 4096
12+
#define ICE_SBQ_MAX_BUF_LEN 512
1213

1314
#define ICE_CTL_Q_DESC(R, i) \
1415
(&(((struct ice_aq_desc *)((R).desc_buf.va))[i]))
@@ -29,6 +30,7 @@ enum ice_ctl_q {
2930
ICE_CTL_Q_UNKNOWN = 0,
3031
ICE_CTL_Q_ADMIN,
3132
ICE_CTL_Q_MAILBOX,
33+
ICE_CTL_Q_SB,
3234
};
3335

3436
/* Control Queue timeout settings - max delay 1s */

drivers/net/ethernet/intel/ice/ice_hw_autogen.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,54 @@
5252
#define PF_MBX_ATQLEN_ATQCRIT_M BIT(30)
5353
#define PF_MBX_ATQLEN_ATQENABLE_M BIT(31)
5454
#define PF_MBX_ATQT 0x0022E300
55+
#define PF_SB_ARQBAH 0x0022FF00
56+
#define PF_SB_ARQBAH_ARQBAH_S 0
57+
#define PF_SB_ARQBAH_ARQBAH_M ICE_M(0xFFFFFFFF, 0)
58+
#define PF_SB_ARQBAL 0x0022FE80
59+
#define PF_SB_ARQBAL_ARQBAL_LSB_S 0
60+
#define PF_SB_ARQBAL_ARQBAL_LSB_M ICE_M(0x3F, 0)
61+
#define PF_SB_ARQBAL_ARQBAL_S 6
62+
#define PF_SB_ARQBAL_ARQBAL_M ICE_M(0x3FFFFFF, 6)
63+
#define PF_SB_ARQH 0x00230000
64+
#define PF_SB_ARQH_ARQH_S 0
65+
#define PF_SB_ARQH_ARQH_M ICE_M(0x3FF, 0)
66+
#define PF_SB_ARQLEN 0x0022FF80
67+
#define PF_SB_ARQLEN_ARQLEN_S 0
68+
#define PF_SB_ARQLEN_ARQLEN_M ICE_M(0x3FF, 0)
69+
#define PF_SB_ARQLEN_ARQVFE_S 28
70+
#define PF_SB_ARQLEN_ARQVFE_M BIT(28)
71+
#define PF_SB_ARQLEN_ARQOVFL_S 29
72+
#define PF_SB_ARQLEN_ARQOVFL_M BIT(29)
73+
#define PF_SB_ARQLEN_ARQCRIT_S 30
74+
#define PF_SB_ARQLEN_ARQCRIT_M BIT(30)
75+
#define PF_SB_ARQLEN_ARQENABLE_S 31
76+
#define PF_SB_ARQLEN_ARQENABLE_M BIT(31)
77+
#define PF_SB_ARQT 0x00230080
78+
#define PF_SB_ARQT_ARQT_S 0
79+
#define PF_SB_ARQT_ARQT_M ICE_M(0x3FF, 0)
80+
#define PF_SB_ATQBAH 0x0022FC80
81+
#define PF_SB_ATQBAH_ATQBAH_S 0
82+
#define PF_SB_ATQBAH_ATQBAH_M ICE_M(0xFFFFFFFF, 0)
83+
#define PF_SB_ATQBAL 0x0022FC00
84+
#define PF_SB_ATQBAL_ATQBAL_S 6
85+
#define PF_SB_ATQBAL_ATQBAL_M ICE_M(0x3FFFFFF, 6)
86+
#define PF_SB_ATQH 0x0022FD80
87+
#define PF_SB_ATQH_ATQH_S 0
88+
#define PF_SB_ATQH_ATQH_M ICE_M(0x3FF, 0)
89+
#define PF_SB_ATQLEN 0x0022FD00
90+
#define PF_SB_ATQLEN_ATQLEN_S 0
91+
#define PF_SB_ATQLEN_ATQLEN_M ICE_M(0x3FF, 0)
92+
#define PF_SB_ATQLEN_ATQVFE_S 28
93+
#define PF_SB_ATQLEN_ATQVFE_M BIT(28)
94+
#define PF_SB_ATQLEN_ATQOVFL_S 29
95+
#define PF_SB_ATQLEN_ATQOVFL_M BIT(29)
96+
#define PF_SB_ATQLEN_ATQCRIT_S 30
97+
#define PF_SB_ATQLEN_ATQCRIT_M BIT(30)
98+
#define PF_SB_ATQLEN_ATQENABLE_S 31
99+
#define PF_SB_ATQLEN_ATQENABLE_M BIT(31)
100+
#define PF_SB_ATQT 0x0022FE00
101+
#define PF_SB_ATQT_ATQT_S 0
102+
#define PF_SB_ATQT_ATQT_M ICE_M(0x3FF, 0)
55103
#define PRTDCB_GENC 0x00083000
56104
#define PRTDCB_GENC_PFCLDA_S 16
57105
#define PRTDCB_GENC_PFCLDA_M ICE_M(0xFFFF, 16)
@@ -169,6 +217,9 @@
169217
#define PFINT_OICR_CTL_ITR_INDX_M ICE_M(0x3, 11)
170218
#define PFINT_OICR_CTL_CAUSE_ENA_M BIT(30)
171219
#define PFINT_OICR_ENA 0x0016C900
220+
#define PFINT_SB_CTL 0x0016B600
221+
#define PFINT_SB_CTL_MSIX_INDX_M ICE_M(0x7FF, 0)
222+
#define PFINT_SB_CTL_CAUSE_ENA_M BIT(30)
172223
#define QINT_RQCTL(_QRX) (0x00150000 + ((_QRX) * 4))
173224
#define QINT_RQCTL_MSIX_INDX_S 0
174225
#define QINT_RQCTL_MSIX_INDX_M ICE_M(0x7FF, 0)

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3392,13 +3392,22 @@ int ice_status_to_errno(enum ice_status err)
33923392
case ICE_ERR_DOES_NOT_EXIST:
33933393
return -ENOENT;
33943394
case ICE_ERR_OUT_OF_RANGE:
3395-
return -ENOTTY;
3395+
case ICE_ERR_AQ_ERROR:
3396+
case ICE_ERR_AQ_TIMEOUT:
3397+
case ICE_ERR_AQ_EMPTY:
3398+
case ICE_ERR_AQ_FW_CRITICAL:
3399+
return -EIO;
33963400
case ICE_ERR_PARAM:
3401+
case ICE_ERR_INVAL_SIZE:
33973402
return -EINVAL;
33983403
case ICE_ERR_NO_MEMORY:
33993404
return -ENOMEM;
34003405
case ICE_ERR_MAX_LIMIT:
34013406
return -EAGAIN;
3407+
case ICE_ERR_RESET_ONGOING:
3408+
return -EBUSY;
3409+
case ICE_ERR_AQ_FULL:
3410+
return -ENOSPC;
34023411
default:
34033412
return -EINVAL;
34043413
}

0 commit comments

Comments
 (0)