From patchwork Wed Jul 10 14:46:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kanas X-Patchwork-Id: 56307 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CF55A4C8E; Wed, 10 Jul 2019 16:47:25 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 20D2CF04 for ; Wed, 10 Jul 2019 16:47:23 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6AEZMZX015338; Wed, 10 Jul 2019 07:47:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : reply-to : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=PVrwuldoJXJloNPdwtnIoY+wJLVeHhy3YcsSxC4tHmY=; b=OaSZD/nPAKR9GluiV7qXkqxYphMiT+e1H9bOig+ZW/fkUpzkzc8WQJuiHYonQDt9CcD2 aQuIUPN32Rglb64ZZ3OerMyFIPhN001w8gBaz+p4E1QN36Emlkz6uJMK1Z/sBqVpMtGG i/iAkmUFlEr2VF5BlPf58Q/cLL7KE9jNmPswTevvrHD4F2jq4jsw1cK5J5IplHikcQDf ungbpVKUjV57Oic1FoWkcgodwc59f70se4NscfGXAMmGq6BqBVlMzPt4Qlgwyjrl9tqH dyIqUAum27pY4yXrDQfVGUnhVEQiu+ckC8WbhCu21riBlwFGpYg+Y8xM+m6byUeeFmau xA== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2tn7d7tbe3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 10 Jul 2019 07:47:23 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 10 Jul 2019 07:47:21 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 10 Jul 2019 07:47:21 -0700 Received: from kk-box-0.marvell.com (unknown [10.95.130.248]) by maili.marvell.com (Postfix) with ESMTP id 316DC3F703F; Wed, 10 Jul 2019 07:47:20 -0700 (PDT) From: To: , Ferruh Yigit , "John W. Linville" CC: Krzysztof Kanas Date: Wed, 10 Jul 2019 16:46:30 +0200 Message-ID: <20190710144630.14926-1-kkanas@marvell.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-10_06:, , signatures=0 Subject: [dpdk-dev] [PATCH v2] net/af_packet: add string error for system errors X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: 27ee549a-d01b-21a5-4a0b-a7e5594b38c0@intel.com List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Krzysztof Kanas Print system error to make easier diagnosis of errors with af_packet. Signed-off-by: Krzysztof Kanas --- drivers/net/af_packet/rte_eth_af_packet.c | 53 ++++++++++------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index db1a751cef5b..d4c899526b3c 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -13,7 +13,9 @@ #include #include #include +#include +#include #include #include #include @@ -103,6 +105,10 @@ static int af_packet_logtype; rte_log(RTE_LOG_ ## level, af_packet_logtype, \ "%s(): " fmt "\n", __func__, ##args) +#define PMD_LOG_ERRNO(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, af_packet_logtype, \ + "%s(): " fmt ":%s\n", __func__, ##args, rte_strerror(errno)) + static uint16_t eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) { @@ -603,9 +609,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, return -1; } if (ioctl(sockfd, SIOCGIFINDEX, &ifr) == -1) { - PMD_LOG(ERR, - "%s: ioctl failed (SIOCGIFINDEX)", - name); + PMD_LOG_ERRNO(ERR, "%s: ioctl failed (SIOCGIFINDEX)", name); return -1; } (*internals)->if_name = strdup(pair->value); @@ -614,9 +618,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, (*internals)->if_index = ifr.ifr_ifindex; if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) == -1) { - PMD_LOG(ERR, - "%s: ioctl failed (SIOCGIFHWADDR)", - name); + PMD_LOG_ERRNO(ERR, "%s: ioctl failed (SIOCGIFHWADDR)", name); return -1; } memcpy(&(*internals)->eth_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN); @@ -638,9 +640,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, /* Open an AF_PACKET socket for this queue... */ qsockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (qsockfd == -1) { - PMD_LOG(ERR, - "%s: could not open AF_PACKET socket", - name); + PMD_LOG_ERRNO(ERR, "%s: could not open AF_PACKET socket", + name); return -1; } @@ -648,9 +649,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, rc = setsockopt(qsockfd, SOL_PACKET, PACKET_VERSION, &tpver, sizeof(tpver)); if (rc == -1) { - PMD_LOG(ERR, - "%s: could not set PACKET_VERSION on AF_PACKET socket for %s", - name, pair->value); + PMD_LOG_ERRNO(ERR, "%s: could not set PACKET_VERSION on AF_PACKET socket for %s:", + name, pair->value); goto error; } @@ -658,9 +658,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, rc = setsockopt(qsockfd, SOL_PACKET, PACKET_LOSS, &discard, sizeof(discard)); if (rc == -1) { - PMD_LOG(ERR, - "%s: could not set PACKET_LOSS on AF_PACKET socket for %s", - name, pair->value); + PMD_LOG_ERRNO(ERR, "%s: could not set PACKET_LOSS on AF_PACKET socket for %s", + name, pair->value); goto error; } @@ -668,9 +667,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, rc = setsockopt(qsockfd, SOL_PACKET, PACKET_QDISC_BYPASS, &qdisc_bypass, sizeof(qdisc_bypass)); if (rc == -1) { - PMD_LOG(ERR, - "%s: could not set PACKET_QDISC_BYPASS on AF_PACKET socket for %s", - name, pair->value); + PMD_LOG_ERRNO(ERR, "%s: could not set PACKET_QDISC_BYPASS on AF_PACKET socket for %s", + name, pair->value); goto error; } #else @@ -679,15 +677,14 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, rc = setsockopt(qsockfd, SOL_PACKET, PACKET_RX_RING, req, sizeof(*req)); if (rc == -1) { - PMD_LOG(ERR, - "%s: could not set PACKET_RX_RING on AF_PACKET socket for %s", - name, pair->value); + PMD_LOG_ERRNO(ERR, "%s: could not set PACKET_RX_RING on AF_PACKE socket for %s", + name, pair->value); goto error; } rc = setsockopt(qsockfd, SOL_PACKET, PACKET_TX_RING, req, sizeof(*req)); if (rc == -1) { - PMD_LOG(ERR, + PMD_LOG_ERRNO(ERR, "%s: could not set PACKET_TX_RING on AF_PACKET " "socket for %s", name, pair->value); goto error; @@ -700,7 +697,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED, qsockfd, 0); if (rx_queue->map == MAP_FAILED) { - PMD_LOG(ERR, + PMD_LOG_ERRNO(ERR, "%s: call to mmap failed on AF_PACKET socket for %s", name, pair->value); goto error; @@ -737,9 +734,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, rc = bind(qsockfd, (const struct sockaddr*)&sockaddr, sizeof(sockaddr)); if (rc == -1) { - PMD_LOG(ERR, - "%s: could not bind AF_PACKET socket to %s", - name, pair->value); + PMD_LOG_ERRNO(ERR, "%s: could not bind AF_PACKET socket to %s", + name, pair->value); goto error; } @@ -747,9 +743,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, rc = setsockopt(qsockfd, SOL_PACKET, PACKET_FANOUT, &fanout_arg, sizeof(fanout_arg)); if (rc == -1) { - PMD_LOG(ERR, - "%s: could not set PACKET_FANOUT on AF_PACKET socket " - "for %s", name, pair->value); + PMD_LOG_ERRNO(ERR, "%s: could not set PACKET_FANOUT on AF_PACKET socket for %s", + name, pair->value); goto error; } #endif