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 6AC07A00C3 for ; Tue, 16 Aug 2022 21:22:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 87F1640DDA; Tue, 16 Aug 2022 21:22:00 +0200 (CEST) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by mails.dpdk.org (Postfix) with ESMTP id B5AC840689 for ; Sun, 14 Aug 2022 10:36:53 +0200 (CEST) Received: by mail-lj1-f169.google.com with SMTP id l10so4904965lje.7 for ; Sun, 14 Aug 2022 01:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:from:to:cc; bh=EcqLh8c48YpN+TQX7R2sxx9Uv6eKL0RaiqHzhijwer4=; b=E6JnWZXT+wVK+s3N0NHfyMGG0X/rSRFmWxBr+h4AW2YCB5TLviXDXtnwj3sUcf+JfD Z5r2FjZueOhJA6HnYVsnj1nVM3kd7100X7ZfvsR+LraIwkCbq/zOO6PGYM9doTyy8slu 2YBudhi09yqAcmmDNIEXWfHyNcLYKEgSKYsUMxRlmgArzIXjjdzxsHnOVEQ+sgh0V0nH H94QyIgNO/QTBRq0Q8k7XXqmBgxXQOvfkRD56CYz/ki7MMMDajoUbMkj2zTn0yTW+E2D FLRPphePJpUoKMXNbpBpH+5JjpxG/yc1HuglgLQ4+iIs+XMex2LB6FjSUDirwI0pLZOV wIow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc; bh=EcqLh8c48YpN+TQX7R2sxx9Uv6eKL0RaiqHzhijwer4=; b=qr+zDd/vuYB+jrmZ4iqFD15I/ihWYL2I71IX7ofvvAXxiUZYrJqsrq0MuPwx8Slba3 SgKYa2MDlkC0Dy3xbDQppOzheHvHi0oqKi168q22sIADUXiTob8buJWOajgUCy2fvKCd 8RIW9OLhqmT73PplgE2Ol7PnVUggMW8XHl/0tBNiE3ImGNp27z094HmloaXha/1lJpnM pwiLPcbxlk2e/z3B5T1Te+QwQS2HByANwIcup8DbiLxFIQvIoWknGgI+pveli2I3a9n5 ou3zPZs62bBPloc1a+JqKiRQaIsfvwzChcagZOdxpogPaZUwmaawQbzJxnJNOzuxAJWL TYaQ== X-Gm-Message-State: ACgBeo1HJiJHPR6fhqMonrA7ysOzg6LUnOCHhuREYEpV1+1mTdBchvwP f+bhnHG7dzHMtHphgx8IanLhz4mLe84= X-Google-Smtp-Source: AA6agR48hX2sQJ+75ngnCLVG3mqDHf/UYAyWaNgiG6UXXdvybzwPb6P1F9P3T1HR9sJH51tYYk4/mA== X-Received: by 2002:a2e:9047:0:b0:25e:68b2:dc20 with SMTP id n7-20020a2e9047000000b0025e68b2dc20mr3342296ljg.399.1660466212613; Sun, 14 Aug 2022 01:36:52 -0700 (PDT) Received: from [192.168.1.45] (141.244.226.109.ip.orionnet.ru. [109.226.244.141]) by smtp.gmail.com with ESMTPSA id d36-20020a0565123d2400b0048aee825e2esm746585lfv.282.2022.08.14.01.36.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 14 Aug 2022 01:36:52 -0700 (PDT) Message-ID: Date: Sun, 14 Aug 2022 15:36:49 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: users@dpdk.org From: Danil Onishchenko Subject: rte_eth_dev_socket_id return Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Tue, 16 Aug 2022 21:21:59 +0200 X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org Hello, I faced a confusing behavior of rte_eth_dev_socket_id() function. In my application I configured eth port and if after that I call rte_eth_dev_socket_id(port) it returns -1. In documentation of the function it is said "Returns: The NUMA socket ID to which the Ethernet device is connected or a default of zero if the socket could not be determined. -1 is returned is the port_id value is out of range.". However if call rte_eth_dev_is_valid_port(port) with the same port id it returns 1. The documentation of this function says "Returns: 0 if port is out of range or not attached, 1 if device is attached". It looks like this functions can't return -1 and 1 respectively for the same port number. Are there any other cases when the first one can return -1? Below is a code sample of port initialization and functions calls static int port_init(uint16_t port, struct rte_mempool *mbuf_pool) {     struct rte_eth_conf port_conf;     int i, retval = 0;     struct rte_ether_addr ether_addr;     struct rte_eth_dev_info dev_info;         struct rte_eth_txconf txconf;         const uint16_t rx_rings = 1, tx_rings = 1;         uint16_t nb_rxd = RX_RING_SIZE, nb_txd = TX_RING_SIZE;         char ethaddr[32];     printf("ETH port found %u %.4x\n", (unsigned int)port, (unsigned int)port);         memset(&port_conf, 0, sizeof(struct rte_eth_conf));     if( !rte_eth_dev_is_valid_port(port) ) {         printf("ETH port rte_eth_dev_is_valid_port(%.4x)==0\n", (unsigned int)port);         return -1;     }     if( (retval = rte_eth_macaddr_get(port, ðer_addr)) != 0 ) {         printf("ETH port rte_eth_macaddr_get(%.4x) != 0\n", (unsigned int)port);         return retval;     }     printf("ETH port %.4x ethernet addr %s\n", (unsigned int)port, eth_addr_to_str(ðer_addr, ethaddr, 32));     if( (retval = rte_eth_dev_info_get(port, &dev_info)) != 0 ) {         printf("ETH port rte_eth_dev_info_get(%.4x) != 0\n", (unsigned int)port);         return retval;     }     printf("Driver name: %s\n", dev_info.driver_name);         if( dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE )                 port_conf.txmode.offloads |= RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;     if( (retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf)) != 0 ) {         printf("ETH port rte_eth_dev_configure(%.4x) != 0\n", (unsigned int)port);                 return retval;     }     if( (retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &nb_rxd, &nb_txd)) != 0 ) {         printf("ETH port rte_eth_dev_adjust_nb_rx_tx_desc(%.4x) != 0\n", (unsigned int)port);         return retval;     }         /* Allocate and set up 1 RX queue per Ethernet port. */         for( i = 0; i < rx_rings; ++i ) {                 if( (retval = rte_eth_rx_queue_setup(port, i, nb_rxd, rte_eth_dev_socket_id(port), NULL, mbuf_pool)) < 0 ) {                     printf("ETH port rte_eth_rx_queue_setup(%.4x) < 0\n", (unsigned int)port);                         return retval;         }         }         txconf = dev_info.default_txconf;         txconf.offloads = port_conf.txmode.offloads;         /* Allocate and set up 1 TX queue per Ethernet port. */         for( i = 0; i < tx_rings; ++i ) {                 if( (retval = rte_eth_tx_queue_setup(port, i, nb_txd, rte_eth_dev_socket_id(port), &txconf)) < 0 ) {                     printf("ETH port rte_eth_tx_queue_setup(%.4x) < 0\n", (unsigned int)port);                         return retval;         }         }     if( (retval = rte_eth_dev_start(port)) < 0 ) {         printf("ETH port rte_eth_dev_start(%.4x) < 0\n", (unsigned int)port);         return retval;     }     if( (retval = rte_eth_macaddr_get(port, ðer_addr)) != 0 ) {         printf("ETH port rte_eth_macaddr_get(%.4x) != 0\n", (unsigned int)port);         goto cleanup;     }     printf("ETH port %.4x ethernet addr %s\n", (unsigned int)port, eth_addr_to_str(ðer_addr, ethaddr, 32));         if( (retval = rte_eth_promiscuous_enable(port)) != 0 ) {             printf("ETH port rte_eth_promiscuous_enable(%.4x) != 0\n", (unsigned int)port);             goto cleanup;     }     printf("PORT %u rte_eth_dev_is_valid_port=%d rte_eth_dev_socket_id=%d\n", (unsigned int)port, rte_eth_dev_is_valid_port(port), rte_eth_dev_socket_id(port)); cleanup:     if( retval != 0 )         if( rte_eth_dev_stop(port) != 0 )             printf("ETH port rte_eth_dev_stop(%.4x) != 0\n", (unsigned int)port); finish:     return retval; } The output of the line printf("PORT %u rte_eth_dev_is_valid_port=%d rte_eth_dev_socket_id=%d\n", (unsigned int)port, rte_eth_dev_is_valid_port(port), rte_eth_dev_socket_id(port)); PORT 0 rte_eth_dev_is_valid_port=1 rte_eth_dev_socket_id=-1 Btw during the start I can see a log message about NUMA if it might help EAL: Detected NUMA nodes: 1