Skip to content

Commit 37bff2b

Browse files
Yuval Mintzdavem330
authored andcommitted
qed: Add VF->PF channel infrastructure
Communication between VF and PF is based on a dedicated HW channel; VF will prepare a messge, and by signaling the HW the PF would get a notification of that message existance. The PF would then copy the message, process it and DMA an answer back to the VF as a response. The messages themselves are TLV-based - allowing easier backward/forward compatibility. This patch adds the infrastructure of the channel on the PF side - starting with the arrival of the notification and ending with DMAing the response back to the VF. It also adds a dummy-response as reference, as it only lays the groundwork of the communication; it doesn't really add support of any actual messages. Signed-off-by: Yuval Mintz <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 32a47e7 commit 37bff2b

File tree

10 files changed

+585
-15
lines changed

10 files changed

+585
-15
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,12 @@ struct qed_hwfn {
378378

379379
struct qed_simd_fp_handler simd_proto_handler[64];
380380

381+
#ifdef CONFIG_QED_SRIOV
382+
struct workqueue_struct *iov_wq;
383+
struct delayed_work iov_task;
384+
unsigned long iov_task_flags;
385+
#endif
386+
381387
struct z_stream_s *stream;
382388
};
383389

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,15 @@ enum qed_dmae_address_type_t {
182182
* used mostly to write a zeroed buffer to destination address
183183
* using DMA
184184
*/
185-
#define QED_DMAE_FLAG_RW_REPL_SRC 0x00000001
186-
#define QED_DMAE_FLAG_COMPLETION_DST 0x00000008
185+
#define QED_DMAE_FLAG_RW_REPL_SRC 0x00000001
186+
#define QED_DMAE_FLAG_VF_SRC 0x00000002
187+
#define QED_DMAE_FLAG_VF_DST 0x00000004
188+
#define QED_DMAE_FLAG_COMPLETION_DST 0x00000008
187189

188190
struct qed_dmae_params {
189-
u32 flags; /* consists of QED_DMAE_FLAG_* values */
191+
u32 flags; /* consists of QED_DMAE_FLAG_* values */
192+
u8 src_vfid;
193+
u8 dst_vfid;
190194
};
191195

192196
/**
@@ -208,6 +212,23 @@ qed_dmae_host2grc(struct qed_hwfn *p_hwfn,
208212
u32 size_in_dwords,
209213
u32 flags);
210214

215+
/**
216+
* @brief qed_dmae_host2host - copy data from to source address
217+
* to a destination adress (for SRIOV) using the given ptt
218+
*
219+
* @param p_hwfn
220+
* @param p_ptt
221+
* @param source_addr
222+
* @param dest_addr
223+
* @param size_in_dwords
224+
* @param params
225+
*/
226+
int qed_dmae_host2host(struct qed_hwfn *p_hwfn,
227+
struct qed_ptt *p_ptt,
228+
dma_addr_t source_addr,
229+
dma_addr_t dest_addr,
230+
u32 size_in_dwords, struct qed_dmae_params *p_params);
231+
211232
/**
212233
* @brief qed_chain_alloc - Allocate and initialize a chain
213234
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ enum common_event_opcode {
3131
COMMON_EVENT_PF_STOP,
3232
COMMON_EVENT_RESERVED,
3333
COMMON_EVENT_RESERVED2,
34-
COMMON_EVENT_RESERVED3,
34+
COMMON_EVENT_VF_PF_CHANNEL,
3535
COMMON_EVENT_RESERVED4,
3636
COMMON_EVENT_RESERVED5,
3737
COMMON_EVENT_RESERVED6,

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

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ static void qed_dmae_opcode(struct qed_hwfn *p_hwfn,
355355
const u8 is_dst_type_grc,
356356
struct qed_dmae_params *p_params)
357357
{
358+
u16 opcode_b = 0;
358359
u32 opcode = 0;
359-
u16 opcodeB = 0;
360360

361361
/* Whether the source is the PCIe or the GRC.
362362
* 0- The source is the PCIe
@@ -398,14 +398,24 @@ static void qed_dmae_opcode(struct qed_hwfn *p_hwfn,
398398
opcode |= (DMAE_CMD_DST_ADDR_RESET_MASK <<
399399
DMAE_CMD_DST_ADDR_RESET_SHIFT);
400400

401-
opcodeB |= (DMAE_CMD_SRC_VF_ID_MASK <<
402-
DMAE_CMD_SRC_VF_ID_SHIFT);
401+
/* SRC/DST VFID: all 1's - pf, otherwise VF id */
402+
if (p_params->flags & QED_DMAE_FLAG_VF_SRC) {
403+
opcode |= 1 << DMAE_CMD_SRC_VF_ID_VALID_SHIFT;
404+
opcode_b |= p_params->src_vfid << DMAE_CMD_SRC_VF_ID_SHIFT;
405+
} else {
406+
opcode_b |= DMAE_CMD_SRC_VF_ID_MASK <<
407+
DMAE_CMD_SRC_VF_ID_SHIFT;
408+
}
403409

404-
opcodeB |= (DMAE_CMD_DST_VF_ID_MASK <<
405-
DMAE_CMD_DST_VF_ID_SHIFT);
410+
if (p_params->flags & QED_DMAE_FLAG_VF_DST) {
411+
opcode |= 1 << DMAE_CMD_DST_VF_ID_VALID_SHIFT;
412+
opcode_b |= p_params->dst_vfid << DMAE_CMD_DST_VF_ID_SHIFT;
413+
} else {
414+
opcode_b |= DMAE_CMD_DST_VF_ID_MASK << DMAE_CMD_DST_VF_ID_SHIFT;
415+
}
406416

407417
p_hwfn->dmae_info.p_dmae_cmd->opcode = cpu_to_le32(opcode);
408-
p_hwfn->dmae_info.p_dmae_cmd->opcode_b = cpu_to_le16(opcodeB);
418+
p_hwfn->dmae_info.p_dmae_cmd->opcode_b = cpu_to_le16(opcode_b);
409419
}
410420

411421
u32 qed_dmae_idx_to_go_cmd(u8 idx)
@@ -753,6 +763,28 @@ int qed_dmae_host2grc(struct qed_hwfn *p_hwfn,
753763
return rc;
754764
}
755765

766+
int
767+
qed_dmae_host2host(struct qed_hwfn *p_hwfn,
768+
struct qed_ptt *p_ptt,
769+
dma_addr_t source_addr,
770+
dma_addr_t dest_addr,
771+
u32 size_in_dwords, struct qed_dmae_params *p_params)
772+
{
773+
int rc;
774+
775+
mutex_lock(&(p_hwfn->dmae_info.mutex));
776+
777+
rc = qed_dmae_execute_command(p_hwfn, p_ptt, source_addr,
778+
dest_addr,
779+
QED_DMAE_ADDRESS_HOST_PHYS,
780+
QED_DMAE_ADDRESS_HOST_PHYS,
781+
size_in_dwords, p_params);
782+
783+
mutex_unlock(&(p_hwfn->dmae_info.mutex));
784+
785+
return rc;
786+
}
787+
756788
u16 qed_get_qm_pq(struct qed_hwfn *p_hwfn,
757789
enum protocol_type proto,
758790
union qed_qm_pq_params *p_params)

drivers/net/ethernet/qlogic/qed/qed_main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/qed/qed_if.h>
2525

2626
#include "qed.h"
27+
#include "qed_sriov.h"
2728
#include "qed_sp.h"
2829
#include "qed_dev_api.h"
2930
#include "qed_mcp.h"
@@ -749,7 +750,10 @@ static int qed_slowpath_start(struct qed_dev *cdev,
749750
struct qed_mcp_drv_version drv_version;
750751
const u8 *data = NULL;
751752
struct qed_hwfn *hwfn;
752-
int rc;
753+
int rc = -EINVAL;
754+
755+
if (qed_iov_wq_start(cdev))
756+
goto err;
753757

754758
rc = request_firmware(&cdev->firmware, QED_FW_FILE_NAME,
755759
&cdev->pdev->dev);
@@ -826,6 +830,8 @@ static int qed_slowpath_start(struct qed_dev *cdev,
826830
err:
827831
release_firmware(cdev->firmware);
828832

833+
qed_iov_wq_stop(cdev, false);
834+
829835
return rc;
830836
}
831837

@@ -842,6 +848,8 @@ static int qed_slowpath_stop(struct qed_dev *cdev)
842848
qed_disable_msix(cdev);
843849
qed_nic_reset(cdev);
844850

851+
qed_iov_wq_stop(cdev, true);
852+
845853
release_firmware(cdev->firmware);
846854

847855
return 0;

drivers/net/ethernet/qlogic/qed/qed_spq.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "qed_mcp.h"
2828
#include "qed_reg_addr.h"
2929
#include "qed_sp.h"
30+
#include "qed_sriov.h"
3031

3132
/***************************************************************************
3233
* Structures & Definitions
@@ -242,10 +243,17 @@ static int
242243
qed_async_event_completion(struct qed_hwfn *p_hwfn,
243244
struct event_ring_entry *p_eqe)
244245
{
245-
DP_NOTICE(p_hwfn,
246-
"Unknown Async completion for protocol: %d\n",
247-
p_eqe->protocol_id);
248-
return -EINVAL;
246+
switch (p_eqe->protocol_id) {
247+
case PROTOCOLID_COMMON:
248+
return qed_sriov_eqe_event(p_hwfn,
249+
p_eqe->opcode,
250+
p_eqe->echo, &p_eqe->data);
251+
default:
252+
DP_NOTICE(p_hwfn,
253+
"Unknown Async completion for protocol: %d\n",
254+
p_eqe->protocol_id);
255+
return -EINVAL;
256+
}
249257
}
250258

251259
/***************************************************************************

0 commit comments

Comments
 (0)