DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Junlong Wang <wang.junlong1@zte.com.cn>
Cc: dev@dpdk.org, stephen@networkplumber.org, ferruh.yigit@amd.com,
	wang.yong19@zte.com.cn
Subject: Re: [PATCH v6 5/9] net/zxdh: add msg chan enable implementation
Date: Mon, 21 Oct 2024 10:50:52 +0200	[thread overview]
Message-ID: <10302806.L8ug28u51p@thomas> (raw)
In-Reply-To: <20241016081824.1808433-4-wang.junlong1@zte.com.cn>

16/10/2024 10:18, Junlong Wang:
> Add msg chan enable implementation to support
> send msg to get infos.

Would be interesting to explain which module is receiving the message.


> +union VPORT {

Why uppercase? for differenciate with vport below?
In general we tend to use only lowercase.

> +	uint16_t vport;
> +	struct {
> +		uint16_t vfid:8;
> +		uint16_t pfid:3;
> +		uint16_t vf_flag:1;
> +		uint16_t epid:3;
> +		uint16_t direct_flag:1;
> +	};
> +};


I am curious about the spinlock function below.
What is it doing exactly?

> +static int32_t zxdh_spinlock_lock(uint32_t virt_lock_id, uint64_t virt_addr,
> +					uint64_t label_addr, uint16_t primary_id)
> +{
> +	uint32_t lock_rd_cnt = 0;
> +
> +	do {
> +		/* read to lock */
> +		uint8_t spl_val = spinklock_read(virt_addr, virt_lock_id);

typo, it should be spinlock_read

> +
> +		if (spl_val == 0) {
> +			label_write((uint64_t)label_addr, virt_lock_id, primary_id);
> +			break;
> +		}
> +		rte_delay_us_block(SPINLOCK_POLLING_SPAN_US);
> +		lock_rd_cnt++;
> +	} while (lock_rd_cnt < MAX_HARD_SPINLOCK_ASK_TIMES);
> +	if (lock_rd_cnt >= MAX_HARD_SPINLOCK_ASK_TIMES)
> +		return -1;
> +
> +	return 0;
> +}

[...]
> +pthread_spinlock_t chan_lock;
> +static int zxdh_bar_chan_lock(uint8_t src, uint8_t dst, uint16_t src_pcieid, uint64_t virt_addr)
> +{
> +	int ret = 0;
> +	uint8_t src_index = zxdh_bar_msg_src_index_trans(src);
> +	uint8_t dst_index = zxdh_bar_msg_dst_index_trans(dst);
> +
> +	if (src_index == BAR_MSG_SRC_ERR || dst_index == BAR_MSG_DST_ERR) {
> +		PMD_MSG_LOG(ERR, "lock ERR: chan doesn't exist.");
> +		return BAR_MSG_ERR_TYPE;
> +	}
> +	uint16_t idx = lock_type_tbl[src_index][dst_index];
> +
> +	if (idx == LOCK_TYPE_SOFT)
> +		pthread_spin_lock(&chan_lock);

In general we avoid the pthread.h functions.
Do you know we have rte_spinlock_lock()?

> +	else
> +		ret = zxdh_bar_hard_lock(src_pcieid, dst, virt_addr);
> +
> +	if (ret != 0)
> +		PMD_MSG_LOG(ERR, "dev: 0x%x failed to lock.", src_pcieid);
> +
> +	return ret;
> +}

[...]
> --- a/drivers/net/zxdh/zxdh_msg.h
> +++ b/drivers/net/zxdh/zxdh_msg.h
> @@ -13,6 +13,19 @@ extern "C" {
> 
>  #include <ethdev_driver.h>
> 
> +#define ZXDH_MSIX_INTR_MSG_VEC_BASE  1
> +

You should continue using the prefix ZXDH_
These definitions below have a high risk of namespace conflict in future.
Using a namespace prefix is a good practice.

> +#define BAR_MSG_POLLING_SPAN     100
> +#define BAR_MSG_POLL_CNT_PER_MS  (1 * 1000 / BAR_MSG_POLLING_SPAN)
> +#define BAR_MSG_POLL_CNT_PER_S   (1 * 1000 * 1000 / BAR_MSG_POLLING_SPAN)
> +#define BAR_MSG_TIMEOUT_TH       (10 * 1000 * 1000 / BAR_MSG_POLLING_SPAN)
> +
> +#define BAR_CHAN_MSG_SYNC     0
> +
> +#define BAR_MSG_ADDR_CHAN_INTERVAL  (2 * 1024) /* channel size */
> +#define BAR_MSG_PLAYLOAD_OFFSET     (sizeof(struct bar_msg_header))
> +#define BAR_MSG_PAYLOAD_MAX_LEN     (BAR_MSG_ADDR_CHAN_INTERVAL -
> sizeof(struct bar_msg_header)) +
> 
>  enum DRIVER_TYPE {
>  
>      MSG_CHAN_END_MPF = 0,
>      MSG_CHAN_END_PF,
> 
> @@ -20,6 +33,13 @@ enum DRIVER_TYPE {
> 
>      MSG_CHAN_END_RISC,
>  
>  };
> 
> +enum MSG_VEC {
> +    MSIX_FROM_PFVF = ZXDH_MSIX_INTR_MSG_VEC_BASE,
> +    MSIX_FROM_MPF,
> +    MSIX_FROM_RISCV,
> +    MSG_VEC_NUM,
> +};
> +
> 
>  enum BAR_MSG_RTN {
>  
>      BAR_MSG_OK = 0,
>      BAR_MSG_ERR_MSGID,
> 
> @@ -54,10 +74,117 @@ enum BAR_MSG_RTN {
> 
>      BAR_MSG_ERR_SOCKET, /* netlink sockte err */
>  
>  };
> 
> +enum bar_module_id {
> +    BAR_MODULE_DBG = 0, /* 0:  debug */
> +    BAR_MODULE_TBL,     /* 1:  resource table */
> +    BAR_MODULE_MISX,    /* 2:  config msix */
> +    BAR_MODULE_SDA,     /* 3: */
> +    BAR_MODULE_RDMA,    /* 4: */
> +    BAR_MODULE_DEMO,    /* 5:  channel test */
> +    BAR_MODULE_SMMU,    /* 6: */
> +    BAR_MODULE_MAC,     /* 7:  mac rx/tx stats */
> +    BAR_MODULE_VDPA,    /* 8:  vdpa live migration */
> +    BAR_MODULE_VQM,     /* 9:  vqm live migration */
> +    BAR_MODULE_NP,      /* 10: vf msg callback np */
> +    BAR_MODULE_VPORT,   /* 11: get vport */
> +    BAR_MODULE_BDF,     /* 12: get bdf */
> +    BAR_MODULE_RISC_READY, /* 13: */
> +    BAR_MODULE_REVERSE,    /* 14: byte stream reverse */
> +    BAR_MDOULE_NVME,       /* 15: */
> +    BAR_MDOULE_NPSDK,      /* 16: */
> +    BAR_MODULE_NP_TODO,    /* 17: */
> +    MODULE_BAR_MSG_TO_PF,  /* 18: */
> +    MODULE_BAR_MSG_TO_VF,  /* 19: */
> +
> +    MODULE_FLASH = 32,
> +    BAR_MODULE_OFFSET_GET = 33,
> +    BAR_EVENT_OVS_WITH_VCB = 36,
> +
> +    BAR_MSG_MODULE_NUM = 100,
> +};
> +
> +struct msix_para {
> +    uint16_t pcie_id;
> +    uint16_t vector_risc;
> +    uint16_t vector_pfvf;
> +    uint16_t vector_mpf;
> +    uint64_t virt_addr;
> +    uint16_t driver_type; /* refer to DRIVER_TYPE */
> +};
> +
> +struct msix_msg {
> +    uint16_t pcie_id;
> +    uint16_t vector_risc;
> +    uint16_t vector_pfvf;
> +    uint16_t vector_mpf;
> +};
> +
> +struct zxdh_pci_bar_msg {
> +    uint64_t virt_addr; /* bar addr */
> +    void    *payload_addr;
> +    uint16_t payload_len;
> +    uint16_t emec;
> +    uint16_t src; /* refer to BAR_DRIVER_TYPE */
> +    uint16_t dst; /* refer to BAR_DRIVER_TYPE */
> +    uint16_t module_id;
> +    uint16_t src_pcieid;
> +    uint16_t dst_pcieid;
> +    uint16_t usr;
> +};
> +
> +struct bar_msix_reps {
> +    uint16_t pcie_id;
> +    uint16_t check;
> +    uint16_t vport;
> +    uint16_t rsv;
> +} __rte_packed;
> +
> +struct bar_offset_reps {
> +    uint16_t check;
> +    uint16_t rsv;
> +    uint32_t offset;
> +    uint32_t length;
> +} __rte_packed;
> +
> +struct bar_recv_msg {
> +    uint8_t reps_ok;
> +    uint16_t reps_len;
> +    uint8_t rsv;
> +    /* */
> +    union {
> +        struct bar_msix_reps msix_reps;
> +        struct bar_offset_reps offset_reps;
> +    } __rte_packed;
> +} __rte_packed;
> +
> +struct zxdh_msg_recviver_mem {
> +    void *recv_buffer; /* first 4B is head, followed by payload */
> +    uint64_t buffer_len;
> +};
> +
> +struct bar_msg_header {
> +    uint8_t valid : 1; /* used by __bar_chan_msg_valid_set/get */
> +    uint8_t sync  : 1;
> +    uint8_t emec  : 1; /* emergency? */
> +    uint8_t ack   : 1; /* ack msg? */
> +    uint8_t poll  : 1;
> +    uint8_t usr   : 1;
> +    uint8_t rsv;
> +    uint16_t module_id;
> +    uint16_t len;
> +    uint16_t msg_id;
> +    uint16_t src_pcieid;
> +    uint16_t dst_pcieid; /* used in PF-->VF */




  reply	other threads:[~2024-10-21  8:50 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-10 12:00 [PATCH v4] net/zxdh: Provided zxdh basic init Junlong Wang
2024-09-24  1:35 ` [v4] " Junlong Wang
2024-09-25 22:39 ` [PATCH v4] " Ferruh Yigit
2024-09-26  6:49 ` [v4] " Junlong Wang
2024-10-07 21:43 ` [PATCH v4] " Stephen Hemminger
2024-10-15  5:43 ` [PATCH v5 0/9] net/zxdh: introduce net zxdh driver Junlong Wang
2024-10-15  5:43   ` [PATCH v5 1/9] net/zxdh: add zxdh ethdev pmd driver Junlong Wang
2024-10-15  5:44     ` [PATCH v5 2/9] net/zxdh: add logging implementation Junlong Wang
2024-10-15  5:44       ` [PATCH v5 3/9] net/zxdh: add zxdh device pci init implementation Junlong Wang
2024-10-15  5:44       ` [PATCH v5 4/9] net/zxdh: add msg chan and msg hwlock init Junlong Wang
2024-10-15  5:44       ` [PATCH v5 5/9] net/zxdh: add msg chan enable implementation Junlong Wang
2024-10-15  5:44       ` [PATCH v5 6/9] net/zxdh: add zxdh get device backend infos Junlong Wang
2024-10-15  5:44       ` [PATCH v5 7/9] net/zxdh: add configure zxdh intr implementation Junlong Wang
2024-10-15  5:44       ` [PATCH v5 8/9] net/zxdh: add zxdh dev infos get ops Junlong Wang
2024-10-15  5:44       ` [PATCH v5 9/9] net/zxdh: add zxdh dev configure ops Junlong Wang
2024-10-15 15:37         ` Stephen Hemminger
2024-10-15 15:57         ` Stephen Hemminger
2024-10-16  8:16     ` [PATCH v6 0/9] net/zxdh: introduce net zxdh driver Junlong Wang
2024-10-16  8:16       ` [PATCH v6 1/9] net/zxdh: add zxdh ethdev pmd driver Junlong Wang
2024-10-16  8:18         ` [PATCH v6 2/9] net/zxdh: add logging implementation Junlong Wang
2024-10-16  8:18           ` [PATCH v6 3/9] net/zxdh: add zxdh device pci init implementation Junlong Wang
2024-10-16  8:18           ` [PATCH v6 4/9] net/zxdh: add msg chan and msg hwlock init Junlong Wang
2024-10-16  8:18           ` [PATCH v6 5/9] net/zxdh: add msg chan enable implementation Junlong Wang
2024-10-21  8:50             ` Thomas Monjalon [this message]
2024-10-21 10:56             ` Junlong Wang
2024-10-16  8:18           ` [PATCH v6 6/9] net/zxdh: add zxdh get device backend infos Junlong Wang
2024-10-21  8:52             ` Thomas Monjalon
2024-10-16  8:18           ` [PATCH v6 7/9] net/zxdh: add configure zxdh intr implementation Junlong Wang
2024-10-16  8:18           ` [PATCH v6 8/9] net/zxdh: add zxdh dev infos get ops Junlong Wang
2024-10-21  8:54             ` Thomas Monjalon
2024-10-16  8:18           ` [PATCH v6 9/9] net/zxdh: add zxdh dev configure ops Junlong Wang
2024-10-18  5:18             ` [v6,9/9] " Junlong Wang
2024-10-18  6:48               ` David Marchand
2024-10-19 11:17             ` Junlong Wang
2024-10-21  9:03         ` [PATCH v6 1/9] net/zxdh: add zxdh ethdev pmd driver Thomas Monjalon
2024-10-22 12:20         ` [PATCH v7 0/9] net/zxdh: introduce net zxdh driver Junlong Wang
2024-10-22 12:20           ` [PATCH v7 1/9] net/zxdh: add zxdh ethdev pmd driver Junlong Wang
2024-10-22 12:20           ` [PATCH v7 2/9] net/zxdh: add logging implementation Junlong Wang
2024-10-22 12:20           ` [PATCH v7 3/9] net/zxdh: add zxdh device pci init implementation Junlong Wang
2024-10-22 12:20           ` [PATCH v7 4/9] net/zxdh: add msg chan and msg hwlock init Junlong Wang
2024-10-22 12:20           ` [PATCH v7 5/9] net/zxdh: add msg chan enable implementation Junlong Wang
2024-10-22 12:20           ` [PATCH v7 6/9] net/zxdh: add zxdh get device backend infos Junlong Wang
2024-10-22 12:20           ` [PATCH v7 7/9] net/zxdh: add configure zxdh intr implementation Junlong Wang
2024-10-22 12:20           ` [PATCH v7 8/9] net/zxdh: add zxdh dev infos get ops Junlong Wang
2024-10-22 12:20           ` [PATCH v7 9/9] net/zxdh: add zxdh dev configure ops Junlong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10302806.L8ug28u51p@thomas \
    --to=thomas@monjalon.net \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=stephen@networkplumber.org \
    --cc=wang.junlong1@zte.com.cn \
    --cc=wang.yong19@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).