From patchwork Wed Jun 8 15:43:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 632361 X-Patchwork-Delegate: shemminger@vyatta.com 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 3rPt573Hyvz9snm for ; Thu, 9 Jun 2016 01:43:39 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753613AbcFHPng (ORCPT ); Wed, 8 Jun 2016 11:43:36 -0400 Received: from mx0b-000f0801.pphosted.com ([67.231.152.113]:14026 "EHLO mx0b-000f0801.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753517AbcFHPne (ORCPT ); Wed, 8 Jun 2016 11:43:34 -0400 Received: from pps.filterd (m0048192.ppops.net [127.0.0.1]) by mx0b-000f0801.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u58FhMdq020445; Wed, 8 Jun 2016 08:43:31 -0700 Received: from hq1wp-exmb11.corp.brocade.com ([144.49.131.13]) by mx0b-000f0801.pphosted.com with ESMTP id 23e392axtt-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 08 Jun 2016 08:43:30 -0700 Received: from xeon-e3 (172.16.181.50) by Hq1wp-exmb11.corp.brocade.com (10.70.20.185) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Wed, 8 Jun 2016 08:43:28 -0700 Date: Wed, 8 Jun 2016 08:43:42 -0700 From: Stephen Hemminger To: Sridhar Samudrala CC: , , Subject: Re: [PATCH iproute2] tc: f_u32: Add support for skip_hw and skip_sw flags Message-ID: <20160608084342.6a0b63fb@xeon-e3> In-Reply-To: <1465340379-4709-1-git-send-email-sridhar.samudrala@intel.com> References: <1465340379-4709-1-git-send-email-sridhar.samudrala@intel.com> Organization: Brocade MIME-Version: 1.0 X-Originating-IP: [172.16.181.50] X-ClientProxiedBy: hq1wp-excas13.corp.brocade.com (10.70.36.103) To Hq1wp-exmb11.corp.brocade.com (10.70.20.185) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-06-08_05:, , signatures=0 X-Proofpoint-Spam-Reason: safe Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, 7 Jun 2016 15:59:39 -0700 Sridhar Samudrala wrote: > On devices that support TC U32 offloads, these flags enable a filter to be > added only to HW or only to SW. skip_sw and skip_hw are mutually exclusive > flags. By default without any flags, the filter is added to both HW and SW, > but no error checks are done in case of failure to add to HW. > With skip-sw, failure to add to HW is treated as an error. > > Here is a sample script that adds 2 filters, one with skip_sw and the other > with skip_hw flag. > > # add ingress qdisc > tc qdisc add dev p4p1 ingress > > # enable hw tc offload. > ethtool -K p4p1 hw-tc-offload on > > # add u32 filter with skip-sw flag. > tc filter add dev p4p1 parent ffff: protocol ip prio 99 \ > handle 800:0:1 u32 ht 800: flowid 800:1 \ > skip-sw \ > match ip src 192.168.1.0/24 \ > action drop > > # add u32 filter with skip-hw flag. > tc filter add dev p4p1 parent ffff: protocol ip prio 99 \ > handle 800:0:2 u32 ht 800: flowid 800:2 \ > skip-hw \ > match ip src 192.168.2.0/24 \ > action drop > > Signed-off-by: Sridhar Samudrala Patch fails against current iproute2 git --- tc/f_u32.c +++ tc/f_u32.c @@ -1186,6 +1195,16 @@ static int u32_parse_opt(struct filter_util *qu, char *handle, if (sel_ok) addattr_l(n, MAX_MSG, TCA_U32_SEL, &sel, sizeof(sel.sel) + sel.sel.nkeys * sizeof(struct tc_u32_key)); + + if (flags) { + if (!(flags ^ (TCA_CLS_FLAGS_SKIP_HW | TCA_CLS_FLAGS_SKIP_SW))) { + fprintf(stderr, "skip_hw and skip_sw are mutually " + "exclusive flags. Only one can be set\n"); + return -1; + } + addattr_l(n, MAX_MSG, TCA_U32_FLAGS, &flags, 4); + } + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; }