From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 96B2645B61; Thu, 17 Oct 2024 21:30:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 67B1B40265; Thu, 17 Oct 2024 21:30:42 +0200 (CEST) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id EA65E4025F for ; Thu, 17 Oct 2024 21:30:40 +0200 (CEST) Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2e30116efc9so1166962a91.2 for ; Thu, 17 Oct 2024 12:30:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729193440; x=1729798240; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=g7ZsRFUQ8GkwnL/a2FDIatgznsa6p2EBBKgorGoOXnI=; b=LMM3fgvSl3tMiI/lPEJOAxTN6c/x/Ywv3JH/ewWczfV1soYrmv1z6q1YpFdt7PSYgF af+l/Srb9Xa2i4cjRjhpmRNNmBzDhElLUCoEXTVLSQpMubgSyghGxc+UxRvOoYCQIs0g vA0V1URqMjG3XqbY5++Ypd1ClsL5dZtuf4UTWH53PaeiGvJohqaoUu2u9daLUfae/4L/ SpzhxLxnVyiriQ94+yZQyHD7ZDzuYTE/p/sUPKZmjs7XZMDqSDHUdEDepzy9fo4WP9d+ P9Awb8T26aYF9EgUSODtxL2xQaXmmxKKeLkQjxz0/xWWmKWcfle6iX411GcxBXfhQ0eS bfLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729193440; x=1729798240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g7ZsRFUQ8GkwnL/a2FDIatgznsa6p2EBBKgorGoOXnI=; b=V0iV+nOibEgXiTV5Pll1uFK3K+CInSrr6fXQWvxfl+In2iabNddvX370JoewOSzRtu x6Le2SzW1csyGbdYK7SC/hLr4OlcPNe164JxU1bZ8egwAJ1IrAhmIAMckr3JIuHbX/Dt OxPCXIFBnGNJL42Tehs/58e9a9c6ktYuPY4KVXf6pDDfJiIReMfHfkGHF8qa9+iR3zjb rLXi9gYaTtowiXf7lI9WOTM1ihyZZxgBe8BrXFNM0qZAedoQnLwplbQ37qRXYG8zV3ZW FymTN2UinHcmmfLglEQCMqfzvCsafRubTQf5NWJHffcbbuXh/D8axhlYqqbQfljfwTNz 4Dkw== X-Gm-Message-State: AOJu0YxJGHRhVIMu3N9fl6Crz4zKE3q+7Rk2Bq9XSI2dIYV1HMGlni6D FEGmsuKR49UmQgXJ8xt8WkFFkuDRp58OOXu6FjhATidmFbD4cmLhrO/duYUyRRE= X-Google-Smtp-Source: AGHT+IEyaRs2QFzdZWb2HDG+NlmUfzo9jfnFgcFA6XDefz2REViE3KJ5HFRI6Gzc0H/1xlCAIKNoKw== X-Received: by 2002:a17:90a:c590:b0:2e0:d693:7884 with SMTP id 98e67ed59e1d1-2e5616de895mr101238a91.5.1729193440124; Thu, 17 Oct 2024 12:30:40 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e55da3bc3fsm243130a91.42.2024.10.17.12.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 12:30:39 -0700 (PDT) Date: Thu, 17 Oct 2024 12:30:38 -0700 From: Stephen Hemminger To: Hanxiao Li Cc: dev@dpdk.org Subject: Re: [PATCH v11 05/12] common/zsda: configure zsda queue base functions Message-ID: <20241017123038.07400f83@hermes.local> In-Reply-To: <20241017092310.1863628-6-li.hanxiao@zte.com.cn> References: <20241016083328.1809713-2-li.hanxiao@zte.com.cn> <20241017092310.1863628-1-li.hanxiao@zte.com.cn> <20241017092310.1863628-6-li.hanxiao@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, 17 Oct 2024 17:22:02 +0800 Hanxiao Li wrote: > +static int > +zsda_get_queue_cfg_by_id(const struct zsda_pci_device *zsda_pci_dev, > + const uint8_t qid, struct qinfo *qcfg) > +{ > + struct zsda_admin_req_qcfg req = {0}; > + struct zsda_admin_resp_qcfg resp = {0}; > + int ret = 0; > + struct rte_pci_device *pci_dev = > + zsda_devs[zsda_pci_dev->zsda_dev_id].pci_dev; > + > + if (qid >= MAX_QPS_ON_FUNCTION) { > + ZSDA_LOG(ERR, "qid beyond limit!"); > + return ZSDA_FAILED; > + } > + > + zsda_admin_msg_init(pci_dev); > + req.msg_type = ZSDA_ADMIN_QUEUE_CFG_REQ; > + req.qid = qid; > + > + ret = zsda_send_admin_msg(pci_dev, &req, sizeof(req)); > + if (ret) { > + ZSDA_LOG(ERR, "Failed! Send msg"); > + return ret; > + } > + > + ret = zsda_recv_admin_msg(pci_dev, &resp, sizeof(resp)); > + if (ret) { > + ZSDA_LOG(ERR, "Failed! Receive msg"); > + return ret; > + } > + > + memcpy(qcfg, &resp.qcfg, sizeof(*qcfg)); Could this just be a structure assignment and keep type safety. *qcfg = resp.qcfg; > +static int > +zsda_cookie_init(const uint32_t dev_id, struct zsda_qp **qp_addr, > + const uint16_t queue_pair_id, > + const struct zsda_qp_config *zsda_qp_conf) > +{ > + struct zsda_qp *qp = *qp_addr; > + struct rte_pci_device *pci_dev = zsda_devs[dev_id].pci_dev; > + char op_cookie_pool_name[RTE_RING_NAMESIZE]; > + uint32_t i; > + enum zsda_service_type type = zsda_qp_conf->service_type; > + > + if (zsda_qp_conf->nb_descriptors != ZSDA_MAX_DESC) > + ZSDA_LOG(ERR, "Can't create qp for %u descriptors", > + zsda_qp_conf->nb_descriptors); > + > + qp->srv[type].nb_descriptors = zsda_qp_conf->nb_descriptors; > + > + qp->srv[type].op_cookies = rte_zmalloc_socket( > + "zsda PMD op cookie pointer", > + zsda_qp_conf->nb_descriptors * > + sizeof(*qp->srv[type].op_cookies), > + RTE_CACHE_LINE_SIZE, zsda_qp_conf->socket_id); > + > + if (qp->srv[type].op_cookies == NULL) { > + ZSDA_LOG(ERR, E_MALLOC); > + return -ENOMEM; > + } > + > + snprintf(op_cookie_pool_name, RTE_RING_NAMESIZE, "%s%d_cks_%s_qp%hu", > + pci_dev->driver->driver.name, dev_id, > + zsda_qp_conf->service_str, queue_pair_id); > + > + qp->srv[type].op_cookie_pool = rte_mempool_lookup(op_cookie_pool_name); > + if (qp->srv[type].op_cookie_pool == NULL) > + qp->srv[type].op_cookie_pool = rte_mempool_create( > + op_cookie_pool_name, qp->srv[type].nb_descriptors, > + zsda_qp_conf->cookie_size, 64, 0, NULL, NULL, NULL, > + NULL, (int)(rte_socket_id() & 0xfff), 0); > + if (!qp->srv[type].op_cookie_pool) { > + ZSDA_LOG(ERR, E_CREATE); > + goto exit; > + } > + > + for (i = 0; i < qp->srv[type].nb_descriptors; i++) { > + if (rte_mempool_get(qp->srv[type].op_cookie_pool, > + &qp->srv[type].op_cookies[i])) { > + ZSDA_LOG(ERR, "ZSDA PMD Cannot get op_cookie"); > + goto exit; > + } > + memset(qp->srv[type].op_cookies[i], 0, > + zsda_qp_conf->cookie_size); > + } > + return 0; > + > +exit: > + if (qp->srv[type].op_cookie_pool) > + rte_mempool_free(qp->srv[type].op_cookie_pool); No need to check for null with rte_mempool_free. The cocci/nullfree script modifies this