Skip to content

Commit 804c570

Browse files
Michal Kalderondavem330
authored andcommitted
qed: Use dmae to write to widebus registers in fw_funcs
There are several wide-bus registers written to by the fw_funcs that require using the dmae for atomicity. Therefore using the dmae channel functionality was added to the fw_funcs file, since the code is very similar to the previously used code, the structures used were moved to qed_hsi. Due to FW conventions, the names of the flags in the struct changed. Since this required slight modification in the places that set the flags the code was modified to use GET/SET FIELD macros. Signed-off-by: Ariel Elior <ariel.elior@marvell.com> Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 63ddca3 commit 804c570

7 files changed

Lines changed: 142 additions & 91 deletions

File tree

‎drivers/net/ethernet/qlogic/qed/qed_dev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ qed_llh_access_filter(struct qed_hwfn *p_hwfn,
907907
/* Filter value */
908908
addr = NIG_REG_LLH_FUNC_FILTER_VALUE + 2 * filter_idx * 0x4;
909909

910-
params.flags = QED_DMAE_FLAG_PF_DST;
910+
SET_FIELD(params.flags, QED_DMAE_PARAMS_DST_PF_VALID, 0x1);
911911
params.dst_pfid = pfid;
912912
rc = qed_dmae_host2grc(p_hwfn,
913913
p_ptt,

‎drivers/net/ethernet/qlogic/qed/qed_dev_api.h‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -230,30 +230,6 @@ enum qed_dmae_address_type_t {
230230
QED_DMAE_ADDRESS_GRC
231231
};
232232

233-
/* value of flags If QED_DMAE_FLAG_RW_REPL_SRC flag is set and the
234-
* source is a block of length DMAE_MAX_RW_SIZE and the
235-
* destination is larger, the source block will be duplicated as
236-
* many times as required to fill the destination block. This is
237-
* used mostly to write a zeroed buffer to destination address
238-
* using DMA
239-
*/
240-
#define QED_DMAE_FLAG_RW_REPL_SRC 0x00000001
241-
#define QED_DMAE_FLAG_VF_SRC 0x00000002
242-
#define QED_DMAE_FLAG_VF_DST 0x00000004
243-
#define QED_DMAE_FLAG_COMPLETION_DST 0x00000008
244-
#define QED_DMAE_FLAG_PORT 0x00000010
245-
#define QED_DMAE_FLAG_PF_SRC 0x00000020
246-
#define QED_DMAE_FLAG_PF_DST 0x00000040
247-
248-
struct qed_dmae_params {
249-
u32 flags; /* consists of QED_DMAE_FLAG_* values */
250-
u8 src_vfid;
251-
u8 dst_vfid;
252-
u8 port_id;
253-
u8 src_pfid;
254-
u8 dst_pfid;
255-
};
256-
257233
/**
258234
* @brief qed_dmae_host2grc - copy data from source addr to
259235
* dmae registers using the given ptt

‎drivers/net/ethernet/qlogic/qed/qed_hsi.h‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,11 @@ struct dmae_cmd {
14351435
__le16 crc16;
14361436
__le16 crc16_c;
14371437
__le16 crc10;
1438-
__le16 reserved;
1438+
__le16 error_bit_reserved;
1439+
#define DMAE_CMD_ERROR_BIT_MASK 0x1
1440+
#define DMAE_CMD_ERROR_BIT_SHIFT 0
1441+
#define DMAE_CMD_RESERVED_MASK 0x7FFF
1442+
#define DMAE_CMD_RESERVED_SHIFT 1
14391443
__le16 xsum16;
14401444
__le16 xsum8;
14411445
};
@@ -1566,6 +1570,41 @@ struct e4_ystorm_core_conn_ag_ctx {
15661570
__le32 reg3;
15671571
};
15681572

1573+
/* DMAE parameters */
1574+
struct qed_dmae_params {
1575+
u32 flags;
1576+
/* If QED_DMAE_PARAMS_RW_REPL_SRC flag is set and the
1577+
* source is a block of length DMAE_MAX_RW_SIZE and the
1578+
* destination is larger, the source block will be duplicated as
1579+
* many times as required to fill the destination block. This is
1580+
* used mostly to write a zeroed buffer to destination address
1581+
* using DMA
1582+
*/
1583+
#define QED_DMAE_PARAMS_RW_REPL_SRC_MASK 0x1
1584+
#define QED_DMAE_PARAMS_RW_REPL_SRC_SHIFT 0
1585+
#define QED_DMAE_PARAMS_SRC_VF_VALID_MASK 0x1
1586+
#define QED_DMAE_PARAMS_SRC_VF_VALID_SHIFT 1
1587+
#define QED_DMAE_PARAMS_DST_VF_VALID_MASK 0x1
1588+
#define QED_DMAE_PARAMS_DST_VF_VALID_SHIFT 2
1589+
#define QED_DMAE_PARAMS_COMPLETION_DST_MASK 0x1
1590+
#define QED_DMAE_PARAMS_COMPLETION_DST_SHIFT 3
1591+
#define QED_DMAE_PARAMS_PORT_VALID_MASK 0x1
1592+
#define QED_DMAE_PARAMS_PORT_VALID_SHIFT 4
1593+
#define QED_DMAE_PARAMS_SRC_PF_VALID_MASK 0x1
1594+
#define QED_DMAE_PARAMS_SRC_PF_VALID_SHIFT 5
1595+
#define QED_DMAE_PARAMS_DST_PF_VALID_MASK 0x1
1596+
#define QED_DMAE_PARAMS_DST_PF_VALID_SHIFT 6
1597+
#define QED_DMAE_PARAMS_RESERVED_MASK 0x1FFFFFF
1598+
#define QED_DMAE_PARAMS_RESERVED_SHIFT 7
1599+
u8 src_vfid;
1600+
u8 dst_vfid;
1601+
u8 port_id;
1602+
u8 src_pfid;
1603+
u8 dst_pfid;
1604+
u8 reserved1;
1605+
__le16 reserved2;
1606+
};
1607+
15691608
/* IGU cleanup command */
15701609
struct igu_cleanup {
15711610
__le32 sb_id_and_flags;

‎drivers/net/ethernet/qlogic/qed/qed_hw.c‎

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ u32 qed_vfid_to_concrete(struct qed_hwfn *p_hwfn, u8 vfid)
393393

394394
/* DMAE */
395395
#define QED_DMAE_FLAGS_IS_SET(params, flag) \
396-
((params) != NULL && ((params)->flags & QED_DMAE_FLAG_##flag))
396+
((params) != NULL && GET_FIELD((params)->flags, QED_DMAE_PARAMS_##flag))
397397

398398
static void qed_dmae_opcode(struct qed_hwfn *p_hwfn,
399399
const u8 is_src_type_grc,
@@ -408,62 +408,55 @@ static void qed_dmae_opcode(struct qed_hwfn *p_hwfn,
408408
* 0- The source is the PCIe
409409
* 1- The source is the GRC.
410410
*/
411-
opcode |= (is_src_type_grc ? DMAE_CMD_SRC_MASK_GRC
412-
: DMAE_CMD_SRC_MASK_PCIE) <<
413-
DMAE_CMD_SRC_SHIFT;
414-
src_pfid = QED_DMAE_FLAGS_IS_SET(p_params, PF_SRC) ?
415-
p_params->src_pfid : p_hwfn->rel_pf_id;
416-
opcode |= ((src_pfid & DMAE_CMD_SRC_PF_ID_MASK) <<
417-
DMAE_CMD_SRC_PF_ID_SHIFT);
411+
SET_FIELD(opcode, DMAE_CMD_SRC,
412+
(is_src_type_grc ? dmae_cmd_src_grc : dmae_cmd_src_pcie));
413+
src_pfid = QED_DMAE_FLAGS_IS_SET(p_params, SRC_PF_VALID) ?
414+
p_params->src_pfid : p_hwfn->rel_pf_id;
415+
SET_FIELD(opcode, DMAE_CMD_SRC_PF_ID, src_pfid);
418416

419417
/* The destination of the DMA can be: 0-None 1-PCIe 2-GRC 3-None */
420-
opcode |= (is_dst_type_grc ? DMAE_CMD_DST_MASK_GRC
421-
: DMAE_CMD_DST_MASK_PCIE) <<
422-
DMAE_CMD_DST_SHIFT;
423-
dst_pfid = QED_DMAE_FLAGS_IS_SET(p_params, PF_DST) ?
424-
p_params->dst_pfid : p_hwfn->rel_pf_id;
425-
opcode |= ((dst_pfid & DMAE_CMD_DST_PF_ID_MASK) <<
426-
DMAE_CMD_DST_PF_ID_SHIFT);
418+
SET_FIELD(opcode, DMAE_CMD_DST,
419+
(is_dst_type_grc ? dmae_cmd_dst_grc : dmae_cmd_dst_pcie));
420+
dst_pfid = QED_DMAE_FLAGS_IS_SET(p_params, DST_PF_VALID) ?
421+
p_params->dst_pfid : p_hwfn->rel_pf_id;
422+
SET_FIELD(opcode, DMAE_CMD_DST_PF_ID, dst_pfid);
423+
427424

428425
/* Whether to write a completion word to the completion destination:
429426
* 0-Do not write a completion word
430427
* 1-Write the completion word
431428
*/
432-
opcode |= (DMAE_CMD_COMP_WORD_EN_MASK << DMAE_CMD_COMP_WORD_EN_SHIFT);
433-
opcode |= (DMAE_CMD_SRC_ADDR_RESET_MASK <<
434-
DMAE_CMD_SRC_ADDR_RESET_SHIFT);
429+
SET_FIELD(opcode, DMAE_CMD_COMP_WORD_EN, 1);
430+
SET_FIELD(opcode, DMAE_CMD_SRC_ADDR_RESET, 1);
435431

436432
if (QED_DMAE_FLAGS_IS_SET(p_params, COMPLETION_DST))
437-
opcode |= (1 << DMAE_CMD_COMP_FUNC_SHIFT);
433+
SET_FIELD(opcode, DMAE_CMD_COMP_FUNC, 1);
438434

439-
opcode |= (DMAE_CMD_ENDIANITY << DMAE_CMD_ENDIANITY_MODE_SHIFT);
435+
/* swapping mode 3 - big endian */
436+
SET_FIELD(opcode, DMAE_CMD_ENDIANITY_MODE, DMAE_CMD_ENDIANITY);
440437

441-
port_id = (QED_DMAE_FLAGS_IS_SET(p_params, PORT)) ?
442-
p_params->port_id : p_hwfn->port_id;
443-
opcode |= (port_id << DMAE_CMD_PORT_ID_SHIFT);
438+
port_id = (QED_DMAE_FLAGS_IS_SET(p_params, PORT_VALID)) ?
439+
p_params->port_id : p_hwfn->port_id;
440+
SET_FIELD(opcode, DMAE_CMD_PORT_ID, port_id);
444441

445442
/* reset source address in next go */
446-
opcode |= (DMAE_CMD_SRC_ADDR_RESET_MASK <<
447-
DMAE_CMD_SRC_ADDR_RESET_SHIFT);
443+
SET_FIELD(opcode, DMAE_CMD_SRC_ADDR_RESET, 1);
448444

449445
/* reset dest address in next go */
450-
opcode |= (DMAE_CMD_DST_ADDR_RESET_MASK <<
451-
DMAE_CMD_DST_ADDR_RESET_SHIFT);
446+
SET_FIELD(opcode, DMAE_CMD_DST_ADDR_RESET, 1);
452447

453448
/* SRC/DST VFID: all 1's - pf, otherwise VF id */
454-
if (QED_DMAE_FLAGS_IS_SET(p_params, VF_SRC)) {
455-
opcode |= 1 << DMAE_CMD_SRC_VF_ID_VALID_SHIFT;
456-
opcode_b |= p_params->src_vfid << DMAE_CMD_SRC_VF_ID_SHIFT;
449+
if (QED_DMAE_FLAGS_IS_SET(p_params, SRC_VF_VALID)) {
450+
SET_FIELD(opcode, DMAE_CMD_SRC_VF_ID_VALID, 1);
451+
SET_FIELD(opcode_b, DMAE_CMD_SRC_VF_ID, p_params->src_vfid);
457452
} else {
458-
opcode_b |= DMAE_CMD_SRC_VF_ID_MASK <<
459-
DMAE_CMD_SRC_VF_ID_SHIFT;
453+
SET_FIELD(opcode_b, DMAE_CMD_SRC_VF_ID, 0xFF);
460454
}
461-
462-
if (QED_DMAE_FLAGS_IS_SET(p_params, VF_DST)) {
463-
opcode |= 1 << DMAE_CMD_DST_VF_ID_VALID_SHIFT;
464-
opcode_b |= p_params->dst_vfid << DMAE_CMD_DST_VF_ID_SHIFT;
455+
if (QED_DMAE_FLAGS_IS_SET(p_params, DST_VF_VALID)) {
456+
SET_FIELD(opcode, DMAE_CMD_DST_VF_ID_VALID, 1);
457+
SET_FIELD(opcode_b, DMAE_CMD_DST_VF_ID, p_params->dst_vfid);
465458
} else {
466-
opcode_b |= DMAE_CMD_DST_VF_ID_MASK << DMAE_CMD_DST_VF_ID_SHIFT;
459+
SET_FIELD(opcode_b, DMAE_CMD_DST_VF_ID, 0xFF);
467460
}
468461

469462
p_hwfn->dmae_info.p_dmae_cmd->opcode = cpu_to_le32(opcode);

‎drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.c‎

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,56 @@ bool qed_send_qm_stop_cmd(struct qed_hwfn *p_hwfn,
10111011
#define PRS_ETH_TUNN_OUTPUT_FORMAT 0xF4DAB910
10121012
#define PRS_ETH_OUTPUT_FORMAT 0xFFFF4910
10131013

1014+
#define ARR_REG_WR(dev, ptt, addr, arr, arr_size) \
1015+
do { \
1016+
u32 i; \
1017+
\
1018+
for (i = 0; i < (arr_size); i++) \
1019+
qed_wr(dev, ptt, \
1020+
((addr) + (4 * i)), \
1021+
((u32 *)&(arr))[i]); \
1022+
} while (0)
1023+
1024+
/**
1025+
* @brief qed_dmae_to_grc - is an internal function - writes from host to
1026+
* wide-bus registers (split registers are not supported yet)
1027+
*
1028+
* @param p_hwfn - HW device data
1029+
* @param p_ptt - ptt window used for writing the registers.
1030+
* @param p_data - pointer to source data.
1031+
* @param addr - Destination register address.
1032+
* @param len_in_dwords - data length in DWARDS (u32)
1033+
*/
1034+
static int qed_dmae_to_grc(struct qed_hwfn *p_hwfn,
1035+
struct qed_ptt *p_ptt,
1036+
u32 *p_data, u32 addr, u32 len_in_dwords)
1037+
{
1038+
struct qed_dmae_params params = {};
1039+
int rc;
1040+
1041+
if (!p_data)
1042+
return -1;
1043+
1044+
/* Set DMAE params */
1045+
SET_FIELD(params.flags, QED_DMAE_PARAMS_COMPLETION_DST, 1);
1046+
1047+
/* Execute DMAE command */
1048+
rc = qed_dmae_host2grc(p_hwfn, p_ptt,
1049+
(u64)(uintptr_t)(p_data),
1050+
addr, len_in_dwords, &params);
1051+
1052+
/* If not read using DMAE, read using GRC */
1053+
if (rc) {
1054+
DP_VERBOSE(p_hwfn,
1055+
QED_MSG_DEBUG,
1056+
"Failed writing to chip using DMAE, using GRC instead\n");
1057+
/* write to registers using GRC */
1058+
ARR_REG_WR(p_hwfn, p_ptt, addr, p_data, len_in_dwords);
1059+
}
1060+
1061+
return len_in_dwords;
1062+
}
1063+
10141064
void qed_set_vxlan_dest_port(struct qed_hwfn *p_hwfn,
10151065
struct qed_ptt *p_ptt, u16 dest_port)
10161066
{
@@ -1195,6 +1245,8 @@ void qed_set_vxlan_no_l2_enable(struct qed_hwfn *p_hwfn,
11951245

11961246
void qed_gft_disable(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, u16 pf_id)
11971247
{
1248+
struct regpair ram_line = { };
1249+
11981250
/* Disable gft search for PF */
11991251
qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_GFT, 0);
12001252

@@ -1204,12 +1256,9 @@ void qed_gft_disable(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, u16 pf_id)
12041256
qed_wr(p_hwfn, p_ptt, PRS_REG_GFT_CAM + CAM_LINE_SIZE * pf_id, 0);
12051257

12061258
/* Zero ramline */
1207-
qed_wr(p_hwfn,
1208-
p_ptt, PRS_REG_GFT_PROFILE_MASK_RAM + RAM_LINE_SIZE * pf_id, 0);
1209-
qed_wr(p_hwfn,
1210-
p_ptt,
1211-
PRS_REG_GFT_PROFILE_MASK_RAM + RAM_LINE_SIZE * pf_id + REG_SIZE,
1212-
0);
1259+
qed_dmae_to_grc(p_hwfn, p_ptt, (u32 *)&ram_line,
1260+
PRS_REG_GFT_PROFILE_MASK_RAM + RAM_LINE_SIZE * pf_id,
1261+
sizeof(ram_line) / REG_SIZE);
12131262
}
12141263

12151264
void qed_gft_config(struct qed_hwfn *p_hwfn,
@@ -1320,24 +1369,17 @@ void qed_gft_config(struct qed_hwfn *p_hwfn,
13201369

13211370
qed_wr(p_hwfn,
13221371
p_ptt, PRS_REG_SEARCH_NON_IP_AS_GFT, search_non_ip_as_gft);
1323-
qed_wr(p_hwfn,
1324-
p_ptt,
1325-
PRS_REG_GFT_PROFILE_MASK_RAM + RAM_LINE_SIZE * pf_id,
1326-
ram_line.lo);
1327-
qed_wr(p_hwfn,
1328-
p_ptt,
1329-
PRS_REG_GFT_PROFILE_MASK_RAM + RAM_LINE_SIZE * pf_id + REG_SIZE,
1330-
ram_line.hi);
1372+
qed_dmae_to_grc(p_hwfn, p_ptt, (u32 *)&ram_line,
1373+
PRS_REG_GFT_PROFILE_MASK_RAM + RAM_LINE_SIZE * pf_id,
1374+
sizeof(ram_line) / REG_SIZE);
13311375

13321376
/* Set default profile so that no filter match will happen */
1333-
qed_wr(p_hwfn,
1334-
p_ptt,
1335-
PRS_REG_GFT_PROFILE_MASK_RAM + RAM_LINE_SIZE *
1336-
PRS_GFT_CAM_LINES_NO_MATCH, 0xffffffff);
1337-
qed_wr(p_hwfn,
1338-
p_ptt,
1339-
PRS_REG_GFT_PROFILE_MASK_RAM + RAM_LINE_SIZE *
1340-
PRS_GFT_CAM_LINES_NO_MATCH + REG_SIZE, 0x3ff);
1377+
ram_line.lo = 0xffffffff;
1378+
ram_line.hi = 0x3ff;
1379+
qed_dmae_to_grc(p_hwfn, p_ptt, (u32 *)&ram_line,
1380+
PRS_REG_GFT_PROFILE_MASK_RAM + RAM_LINE_SIZE *
1381+
PRS_GFT_CAM_LINES_NO_MATCH,
1382+
sizeof(ram_line) / REG_SIZE);
13411383

13421384
/* Enable gft search */
13431385
qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_GFT, 1);

‎drivers/net/ethernet/qlogic/qed/qed_init_ops.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int qed_init_fill_dmae(struct qed_hwfn *p_hwfn,
215215
* 3. p_hwfb->temp_data,
216216
* 4. fill_count
217217
*/
218-
params.flags = QED_DMAE_FLAG_RW_REPL_SRC;
218+
SET_FIELD(params.flags, QED_DMAE_PARAMS_RW_REPL_SRC, 0x1);
219219
return qed_dmae_host2grc(p_hwfn, p_ptt,
220220
(uintptr_t)(&zero_buffer[0]),
221221
addr, fill_count, &params);

‎drivers/net/ethernet/qlogic/qed/qed_sriov.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static int qed_iov_post_vf_bulletin(struct qed_hwfn *p_hwfn,
352352

353353
/* propagate bulletin board via dmae to vm memory */
354354
memset(&params, 0, sizeof(params));
355-
params.flags = QED_DMAE_FLAG_VF_DST;
355+
SET_FIELD(params.flags, QED_DMAE_PARAMS_DST_VF_VALID, 0x1);
356356
params.dst_vfid = p_vf->abs_vf_id;
357357
return qed_dmae_host2host(p_hwfn, p_ptt, p_vf->bulletin.phys,
358358
p_vf->vf_bulletin, p_vf->bulletin.size / 4,
@@ -1225,8 +1225,8 @@ static void qed_iov_send_response(struct qed_hwfn *p_hwfn,
12251225

12261226
eng_vf_id = p_vf->abs_vf_id;
12271227

1228-
memset(&params, 0, sizeof(struct qed_dmae_params));
1229-
params.flags = QED_DMAE_FLAG_VF_DST;
1228+
memset(&params, 0, sizeof(params));
1229+
SET_FIELD(params.flags, QED_DMAE_PARAMS_DST_VF_VALID, 0x1);
12301230
params.dst_vfid = eng_vf_id;
12311231

12321232
qed_dmae_host2host(p_hwfn, p_ptt, mbx->reply_phys + sizeof(u64),
@@ -4103,8 +4103,9 @@ static int qed_iov_copy_vf_msg(struct qed_hwfn *p_hwfn, struct qed_ptt *ptt,
41034103
if (!vf_info)
41044104
return -EINVAL;
41054105

4106-
memset(&params, 0, sizeof(struct qed_dmae_params));
4107-
params.flags = QED_DMAE_FLAG_VF_SRC | QED_DMAE_FLAG_COMPLETION_DST;
4106+
memset(&params, 0, sizeof(params));
4107+
SET_FIELD(params.flags, QED_DMAE_PARAMS_SRC_VF_VALID, 0x1);
4108+
SET_FIELD(params.flags, QED_DMAE_PARAMS_COMPLETION_DST, 0x1);
41084109
params.src_vfid = vf_info->abs_vf_id;
41094110

41104111
if (qed_dmae_host2host(p_hwfn, ptt,

0 commit comments

Comments
 (0)