From patchwork Tue Nov 11 18:14:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 40608 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ECBD8206A5 for ; Tue, 11 Nov 2014 18:15:37 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id e51sf7182170eek.2 for ; Tue, 11 Nov 2014 10:15:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=LQVRdll8p1ReSzkhGeQT8KkBroP2ivZnmxGu0dKWo38=; b=PDceB5YxJuVeblYG2XgKc/lj0wEH7TGll5BOtczJwX7vIhR4yi5BvNvJ2JT0qjuL0d 4k/BNuD+L0c4MHo6yuvGTndbmy9PjpD1rlFHnNMGDPZ8+TK2JG4IkG7m+zWSTsYTh/d/ R8IFk0S9dUGjEiVlvt6Mv7ZXzH96aE45EqPn/xV9wMIQNGIMYY6G+zIgLnuPL73nJeEX 5RGV9YO6iSyeaLfzwbVDkiNsYd7sPXSJZ0mW3QcwZgevF8zQjEp/OK1of069ctqRn1rs x2HdUZNh5c7Tbl/yqfvgJveWA1iQPrCVHUmZLlxnJeKKqG8GYfVhllf5lgT5kYEMYRls hu0g== X-Gm-Message-State: ALoCoQlvWkuAawJIJlsXrrfEsVFL1UBbVQFSqzluEIrORhExY01IfSRoAgU61wpbOWZ1z6+LIHvt X-Received: by 10.181.27.135 with SMTP id jg7mr5600199wid.5.1415729737141; Tue, 11 Nov 2014 10:15:37 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.227 with SMTP id e3ls637583laa.69.gmail; Tue, 11 Nov 2014 10:15:36 -0800 (PST) X-Received: by 10.112.150.136 with SMTP id ui8mr10446781lbb.60.1415729736747; Tue, 11 Nov 2014 10:15:36 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id p7si18760610lah.133.2014.11.11.10.15.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 10:15:36 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id ge10so10126362lab.16 for ; Tue, 11 Nov 2014 10:15:36 -0800 (PST) X-Received: by 10.152.6.228 with SMTP id e4mr37581709laa.71.1415729736620; Tue, 11 Nov 2014 10:15:36 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp302505lbc; Tue, 11 Nov 2014 10:15:35 -0800 (PST) X-Received: by 10.170.54.216 with SMTP id 207mr25456456ykw.111.1415729735030; Tue, 11 Nov 2014 10:15:35 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id y8si37890062qal.89.2014.11.11.10.15.31 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 11 Nov 2014 10:15:35 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XoFyV-0006jP-7U; Tue, 11 Nov 2014 18:15:31 +0000 Received: from mail-la0-f41.google.com ([209.85.215.41]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XoFyO-0006jF-4N for lng-odp@lists.linaro.org; Tue, 11 Nov 2014 18:15:24 +0000 Received: by mail-la0-f41.google.com with SMTP id s18so10172254lam.28 for ; Tue, 11 Nov 2014 10:15:18 -0800 (PST) X-Received: by 10.112.11.201 with SMTP id s9mr10850816lbb.79.1415729718422; Tue, 11 Nov 2014 10:15:18 -0800 (PST) Received: from localhost.localdomain ([188.92.105.210]) by mx.google.com with ESMTPSA id bk3sm6143870lbc.34.2014.11.11.10.15.11 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 10:15:13 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 11 Nov 2014 21:14:59 +0300 Message-Id: <1415729700-23420-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 X-Topics: patch Subject: [lng-odp] [PATCH 1/2] linux-generic: implement pktio mtu finctions X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Implement pktio mtu functions: odp_pktio_mtu() to get mtu value; odp_pktio_set_mtu() to set mtu value. Signed-off-by: Maxim Uvarov --- platform/linux-generic/include/api/odp_packet_io.h | 20 +++++++++ .../linux-generic/include/odp_packet_io_internal.h | 4 ++ platform/linux-generic/odp_packet_io.c | 50 ++++++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/platform/linux-generic/include/api/odp_packet_io.h b/platform/linux-generic/include/api/odp_packet_io.h index 360636d..b784705 100644 --- a/platform/linux-generic/include/api/odp_packet_io.h +++ b/platform/linux-generic/include/api/odp_packet_io.h @@ -135,6 +135,26 @@ void odp_pktio_set_input(odp_packet_t pkt, odp_pktio_t id); */ odp_pktio_t odp_pktio_get_input(odp_packet_t pkt); +/* + * Configure the MTU for a packet IO interface. + * + * @param[in] id ODP packet IO handle. + * @param[in] mtu The MTU to be applied. + * + * @return 0 on success, -1 on error. + */ +int odp_pktio_set_mtu(odp_pktio_t id, unsigned int mtu); + +/* + * Get the currently configured MTU of a packet IO interface. + * + * @param[in] id ODP packet IO handle. + * @param[out] mtu Pointer to location in which to store the MTU value. + * + * @return 0 on success, -1 on error. + */ +int odp_pktio_mtu(odp_pktio_t id, unsigned int *mtu); + /** * @} */ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 23633ed..ff73970 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -21,6 +21,8 @@ extern "C" { #include #include +#include + /** * Packet IO types */ @@ -38,6 +40,8 @@ struct pktio_entry { odp_pktio_type_t type; /**< pktio type */ pkt_sock_t pkt_sock; /**< using socket API for IO */ pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap API for IO */ + char name[IFNAMSIZ]; /**< name of pktio provided to + pktio_open() */ }; typedef union { diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index f35193f..20fe10a 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -20,6 +20,7 @@ #include #include +#include typedef struct { pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES]; @@ -203,6 +204,7 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool) return ODP_PKTIO_INVALID; done: + strncpy(pktio_entry->s.name, dev, IFNAMSIZ); unlock_entry(pktio_entry); return id; } @@ -476,3 +478,51 @@ int pktin_deq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], int num) return nbr; } + +int odp_pktio_set_mtu(odp_pktio_t id, unsigned int mtu) +{ + pktio_entry_t *pktio_entry = get_entry(id); + int sockfd; + struct ifreq ifr; + int ret; + + if (pktio_entry->s.pkt_sock_mmap.sockfd) + sockfd = pktio_entry->s.pkt_sock_mmap.sockfd; + else + sockfd = pktio_entry->s.pkt_sock.sockfd; + + strncpy(ifr.ifr_name, pktio_entry->s.name, IFNAMSIZ); + ifr.ifr_mtu = mtu; + + ret = ioctl(sockfd, SIOCSIFMTU, (caddr_t)&ifr); + if (ret != 0) { + ODP_ERR("ioctl SIOCSIFMTU error\n"); + return -1; + } + + return 0; +} + +int odp_pktio_mtu(odp_pktio_t id, unsigned int *mtu) +{ + pktio_entry_t *pktio_entry = get_entry(id); + int sockfd; + struct ifreq ifr; + int ret; + + if (pktio_entry->s.pkt_sock_mmap.sockfd) + sockfd = pktio_entry->s.pkt_sock_mmap.sockfd; + else + sockfd = pktio_entry->s.pkt_sock.sockfd; + + strncpy(ifr.ifr_name, pktio_entry->s.name, IFNAMSIZ); + + ret = ioctl(sockfd, SIOCGIFMTU, &ifr); + if (ret != 0) { + ODP_ERR("ioctl SIOCGIFMTU error\n"); + return -1; + } + + *mtu = ifr.ifr_mtu; + return 0; +}