From patchwork Fri Jul 12 10:01:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kanas X-Patchwork-Id: 56405 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 2A1011B9F6; Fri, 12 Jul 2019 12:01:45 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id C609E1B9AC for ; Fri, 12 Jul 2019 12:01:43 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6C9tVKt027764; Fri, 12 Jul 2019 03:01:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=rN8IH0//09jG6hR8V15a1Nt7/7HRfsFcfq57783GDjQ=; b=dFZj3+YBaP9x+YX/VLrtmHmVkOnNFpDiV1EymWJb/St6gdYmCR4IDFdC4msuJHjgKzA7 r1EKnB+NlFF2BULVkyXPq5R64yUiT2xgFsXVpskapC3/ZUfH1UrnlgGkgv9GB/hVGYyE t26a7LvhoqtCwmMYamMoour5JOhyzUJ720ec8ob/dG6i9/dF1iNt7S9BXBrq/De2KQz0 MvaGmzMeqDg6wk+5lNu2bnBXW7sq0rRZnwlDna9KjnTlE/kulaSYcvB6OxsaTZ1CiHLj yp/8ebWUXCyUnU1J2h7gX/CGXQtg9CG0u0jI4h5bO+muV4vxuCE2+vI9O4rH/ZPrMPx+ zQ== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2tpdc82b6n-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 12 Jul 2019 03:01:42 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 12 Jul 2019 03:01:38 -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; Fri, 12 Jul 2019 03:01:37 -0700 Received: from kk-box-0.marvell.com (unknown [10.95.131.32]) by maili.marvell.com (Postfix) with ESMTP id 564FC3F7043; Fri, 12 Jul 2019 03:01:36 -0700 (PDT) From: To: , Stephen Hemminger , "Ferruh Yigit" , "John W. Linville" CC: Krzysztof Kanas Date: Fri, 12 Jul 2019 12:01:21 +0200 Message-ID: <20190712100121.10222-1-kkanas@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190711091038.2ddbd432@hermes.lan> References: <20190711091038.2ddbd432@hermes.lan> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-12_03:, , signatures=0 Subject: [dpdk-dev] [PATCH v3] net/af_packet: add string error for system errors X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list 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 Reviewed-by: Ferruh Yigit --- 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..fdbf7d3be4e7 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -21,6 +22,7 @@ #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, 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