From patchwork Sat Nov 30 12:25:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Graf X-Patchwork-Id: 295575 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C23C62C009C for ; Sat, 30 Nov 2013 23:25:30 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751967Ab3K3MZ1 (ORCPT ); Sat, 30 Nov 2013 07:25:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:23583 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751320Ab3K3MZ0 (ORCPT ); Sat, 30 Nov 2013 07:25:26 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAUCPLhS001079 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 30 Nov 2013 07:25:21 -0500 Received: from localhost.localdomain (vpn1-7-5.ams2.redhat.com [10.36.7.5]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rAUCPJ8H000830; Sat, 30 Nov 2013 07:25:20 -0500 From: Thomas Graf To: jesse@nicira.com Cc: dev@openvswitch.org, netdev@vger.kernel.org Subject: [PATCH v2] linux: Signal datapath that unaligned Netlink message can be received Date: Sat, 30 Nov 2013 13:25:17 +0100 Message-Id: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Following commit (''netlink: Do not enforce alignment of last Netlink attribute''), signal the ability to receive unaligned Netlink messages to the datapath to enable utilization of zerocopy optimizations. Signed-off-by: Thomas Graf --- V2: - Only provide OVS_DP_ATTR_USER_FEATURES on OVS_DP_CMD_NEW include/linux/openvswitch.h | 15 ++++++++++++++- lib/dpif-linux.c | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h index b429201..80266b1 100644 --- a/include/linux/openvswitch.h +++ b/include/linux/openvswitch.h @@ -60,7 +60,16 @@ struct ovs_header { #define OVS_DATAPATH_FAMILY "ovs_datapath" #define OVS_DATAPATH_MCGROUP "ovs_datapath" -#define OVS_DATAPATH_VERSION 0x1 + +/** + * V2: + * - API users are expected to provide OVS_DP_ATTR_USER_FEATURES + * when creating or updating the datapath. + */ +#define OVS_DATAPATH_VERSION 2 + +/* First OVS datapath version to support features */ +#define OVS_DP_VER_FEATURES 2 enum ovs_datapath_cmd { OVS_DP_CMD_UNSPEC, @@ -95,6 +104,7 @@ enum ovs_datapath_attr { OVS_DP_ATTR_UPCALL_PID, /* Netlink PID to receive upcalls */ OVS_DP_ATTR_STATS, /* struct ovs_dp_stats */ OVS_DP_ATTR_MEGAFLOW_STATS, /* struct ovs_dp_megaflow_stats */ + OVS_DP_ATTR_USER_FEATURES, /* OVS_DP_F_* */ __OVS_DP_ATTR_MAX }; @@ -126,6 +136,9 @@ struct ovs_vport_stats { __u64 tx_dropped; /* no space available in linux */ }; +/* Allow last Netlink attribute to be unaligned */ +#define OVS_DP_F_UNALIGNED (1 << 0) + /* Fixed logical ports. */ #define OVSP_LOCAL ((__u32)0) diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c index 6c482d0..2d8a1aa 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -73,6 +73,7 @@ struct dpif_linux_dp { /* Attributes. */ const char *name; /* OVS_DP_ATTR_NAME. */ const uint32_t *upcall_pid; /* OVS_DP_ATTR_UPCALL_PID. */ + uint32_t user_features; /* OVS_DP_ATTR_USER_FEATURES */ struct ovs_dp_stats stats; /* OVS_DP_ATTR_STATS. */ struct ovs_dp_megaflow_stats megaflow_stats; /* OVS_DP_ATTR_MEGAFLOW_STATS.*/ @@ -228,6 +229,7 @@ dpif_linux_open(const struct dpif_class *class OVS_UNUSED, const char *name, dp_request.cmd = OVS_DP_CMD_NEW; upcall_pid = 0; dp_request.upcall_pid = &upcall_pid; + dp_request.user_features |= OVS_DP_F_UNALIGNED; } else { dp_request.cmd = OVS_DP_CMD_GET; } @@ -1839,6 +1841,10 @@ dpif_linux_dp_to_ofpbuf(const struct dpif_linux_dp *dp, struct ofpbuf *buf) nl_msg_put_u32(buf, OVS_DP_ATTR_UPCALL_PID, *dp->upcall_pid); } + if (dp->user_features) { + nl_msg_put_u32(buf, OVS_DP_ATTR_USER_FEATURES, dp->user_features); + } + /* Skip OVS_DP_ATTR_STATS since we never have a reason to serialize it. */ }