Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1492537ybl; Wed, 28 Aug 2019 15:52:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKwWDqutJFSPdOD6jJypCEjYY/V1/yBJnDIhbhfZNOm/tkVEWhQYvaHMUWyaZ5puS70htP X-Received: by 2002:a17:90a:f98e:: with SMTP id cq14mr6698748pjb.52.1567032766033; Wed, 28 Aug 2019 15:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567032766; cv=none; d=google.com; s=arc-20160816; b=wGcaD4Hkmqc0Z+aOFRcn+kU2u4gYmhIRMq98XR1uj9Oi8/nmTVFbm2isyMSPQ/8qIp gON4pYd4WlOICf6WR/n2MsUsya7XVox9NTIJvHeGcU1+wTaufDO+pfpnDiqrMFI9b9/Z eMh173YPw5wff6NAybFNOzDkl22LB1Vntq1XhuFgSxibZJbIGXvxyGfC/Wik5eQum69E ugcygPY0jnzzFmIO+ryZjBSmQpgaQAIma9+59fJDrmQz0yie2WluiyZic5qQMmY1movp eTD8X4ePB0pcsCBggDO3DuYeZWqI9qM3VZwivneAuunaIKQ1l4v16huN99oq+PEemYK/ 5h6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=P4f75AU1DJxnFvqYS/9DIutvhEGbkQCOM9YxYG2SPJ0=; b=KgXbbHIIALs3m+Us7P6S7d0lpzzrC1GiKt3kvdzZ6+aKT7QcEAiZvWDF6FjrcgF5wK aCHagYFRLP4v1fVO93rAQeEYI/MvJIlCXDwBW9ixmLPvkbal0X32b+A4yl8V8Wx77dZN WAu4UZKbDrKggL+ZCQNvxQdWjYbbAkdzD45RhjM+xLo0p54ghU75cMAt0D+b+HkUvvIl 872Zze/fdlS8MTFeyRFjjGZ1Md+T20WIidTeZeieGUykBJ3auuO1u+A9PdCI8bNj0OBo cAbq5tVrXMBLXbuYiMPyp9s2uv+xsFvKy9G+Rrk5YVfRR2laxuyDL2ylf0WcjgbvJZ5O V4/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v19si553672pfm.56.2019.08.28.15.52.29; Wed, 28 Aug 2019 15:52:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727024AbfH1Wvi (ORCPT + 99 others); Wed, 28 Aug 2019 18:51:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:5870 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbfH1Wvi (ORCPT ); Wed, 28 Aug 2019 18:51:38 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7SMlXMX108629; Wed, 28 Aug 2019 18:51:34 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2up1m3hwb2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Aug 2019 18:51:33 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x7SMn8s5112837; Wed, 28 Aug 2019 18:51:33 -0400 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 2up1m3hwap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Aug 2019 18:51:33 -0400 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x7SMj48P018800; Wed, 28 Aug 2019 22:51:32 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma05wdc.us.ibm.com with ESMTP id 2ujvv78pdn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Aug 2019 22:51:32 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x7SMpVPD49021352 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Aug 2019 22:51:31 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0DFEEC6070; Wed, 28 Aug 2019 22:51:31 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 735CBC6062; Wed, 28 Aug 2019 22:51:30 +0000 (GMT) Received: from oc5348122405.ibm.com.austin.ibm.com (unknown [9.53.179.215]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 28 Aug 2019 22:51:30 +0000 (GMT) From: David Dai To: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: zdai@us.ibm.com, zdai@linux.vnet.ibm.com Subject: [v1] net_sched: act_police: add 2 new attributes to support police 64bit rate and peakrate Date: Wed, 28 Aug 2019 17:51:27 -0500 Message-Id: <1567032687-973-1-git-send-email-zdai@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-28_12:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908280218 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For high speed adapter like Mellanox CX-5 card, it can reach upto 100 Gbits per second bandwidth. Currently htb already supports 64bit rate in tc utility. However police action rate and peakrate are still limited to 32bit value (upto 32 Gbits per second). Add 2 new attributes TCA_POLICE_RATE64 and TCA_POLICE_RATE64 in kernel for 64bit support so that tc utility can use them for 64bit rate and peakrate value to break the 32bit limit, and still keep the backward binary compatibility. Tested-by: David Dai Signed-off-by: David Dai --- include/uapi/linux/pkt_cls.h | 2 ++ net/sched/act_police.c | 27 +++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index b057aee..eb4ea4d 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -159,6 +159,8 @@ enum { TCA_POLICE_AVRATE, TCA_POLICE_RESULT, TCA_POLICE_TM, + TCA_POLICE_RATE64, + TCA_POLICE_PEAKRATE64, TCA_POLICE_PAD, __TCA_POLICE_MAX #define TCA_POLICE_RESULT TCA_POLICE_RESULT diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 49cec3e..ed5372e 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -40,6 +40,8 @@ static int tcf_police_walker(struct net *net, struct sk_buff *skb, [TCA_POLICE_PEAKRATE] = { .len = TC_RTAB_SIZE }, [TCA_POLICE_AVRATE] = { .type = NLA_U32 }, [TCA_POLICE_RESULT] = { .type = NLA_U32 }, + [TCA_POLICE_RATE64] = { .type = NLA_U64 }, + [TCA_POLICE_PEAKRATE64] = { .type = NLA_U64 }, }; static int tcf_police_init(struct net *net, struct nlattr *nla, @@ -58,6 +60,7 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, struct tcf_police_params *new; bool exists = false; u32 index; + u64 rate64, prate64; if (nla == NULL) return -EINVAL; @@ -155,14 +158,18 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, } if (R_tab) { new->rate_present = true; - psched_ratecfg_precompute(&new->rate, &R_tab->rate, 0); + rate64 = tb[TCA_POLICE_RATE64] ? + nla_get_u64(tb[TCA_POLICE_RATE64]) : 0; + psched_ratecfg_precompute(&new->rate, &R_tab->rate, rate64); qdisc_put_rtab(R_tab); } else { new->rate_present = false; } if (P_tab) { new->peak_present = true; - psched_ratecfg_precompute(&new->peak, &P_tab->rate, 0); + prate64 = tb[TCA_POLICE_PEAKRATE64] ? + nla_get_u64(tb[TCA_POLICE_PEAKRATE64]) : 0; + psched_ratecfg_precompute(&new->peak, &P_tab->rate, prate64); qdisc_put_rtab(P_tab); } else { new->peak_present = false; @@ -313,10 +320,22 @@ static int tcf_police_dump(struct sk_buff *skb, struct tc_action *a, lockdep_is_held(&police->tcf_lock)); opt.mtu = p->tcfp_mtu; opt.burst = PSCHED_NS2TICKS(p->tcfp_burst); - if (p->rate_present) + if (p->rate_present) { psched_ratecfg_getrate(&opt.rate, &p->rate); - if (p->peak_present) + if ((police->params->rate.rate_bytes_ps >= (1ULL << 32)) && + nla_put_u64_64bit(skb, TCA_POLICE_RATE64, + police->params->rate.rate_bytes_ps, + TCA_POLICE_PAD)) + goto nla_put_failure; + } + if (p->peak_present) { psched_ratecfg_getrate(&opt.peakrate, &p->peak); + if ((police->params->peak.rate_bytes_ps >= (1ULL << 32)) && + nla_put_u64_64bit(skb, TCA_POLICE_PEAKRATE64, + police->params->peak.rate_bytes_ps, + TCA_POLICE_PAD)) + goto nla_put_failure; + } if (nla_put(skb, TCA_POLICE_TBF, sizeof(opt), &opt)) goto nla_put_failure; if (p->tcfp_result && -- 1.7.1