Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752436AbdLKXg7 (ORCPT ); Mon, 11 Dec 2017 18:36:59 -0500 Received: from mail-pf0-f179.google.com ([209.85.192.179]:39357 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751274AbdLKXgp (ORCPT ); Mon, 11 Dec 2017 18:36:45 -0500 X-Google-Smtp-Source: ACJfBose+F3yAJrZ0pPjaRYQBn3waNR/O8Fv7OvH/TjH0qvgy5rJLzrWUuYKG0P2NZJrTDUgmD8vzA== Date: Mon, 11 Dec 2017 15:36:41 -0800 From: Richard Cochran To: Aleksey Makarov Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "Goutham, Sunil" , Radoslaw Biernacki , Robert Richter , David Daney , Philippe Ombredanne , Sunil Goutham Subject: Re: [PATCH net-next v5 2/2] net: thunderx: add timestamping support Message-ID: <20171211233641.cs7zdw34qkngicmj@localhost> References: <20171211141435.2915-1-aleksey.makarov@cavium.com> <20171211141435.2915-3-aleksey.makarov@cavium.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171211141435.2915-3-aleksey.makarov@cavium.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1808 Lines: 55 On Mon, Dec 11, 2017 at 05:14:31PM +0300, Aleksey Makarov wrote: > @@ -880,6 +889,46 @@ static void nic_pause_frame(struct nicpf *nic, int vf, struct pfc *cfg) > } > } > > +/* Enable or disable HW timestamping by BGX for pkts received on a LMAC */ > +static void nic_config_timestamp(struct nicpf *nic, int vf, struct set_ptp *ptp) > +{ > + struct pkind_cfg *pkind; > + u8 lmac, bgx_idx; > + u64 pkind_val, pkind_idx; > + > + if (vf >= nic->num_vf_en) > + return; > + > + bgx_idx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); > + lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); > + > + pkind_idx = lmac + bgx_idx * MAX_LMAC_PER_BGX; > + pkind_val = nic_reg_read(nic, NIC_PF_PKIND_0_15_CFG | (pkind_idx << 3)); > + pkind = (struct pkind_cfg *)&pkind_val; > + > + if (ptp->enable && !pkind->hdr_sl) { > + /* Skiplen to exclude 8byte timestamp while parsing pkt > + * If not configured, will result in L2 errors. > + */ > + pkind->hdr_sl = 4; > + /* Adjust max packet length allowed */ > + pkind->maxlen += (pkind->hdr_sl * 2); > + bgx_config_timestamping(nic->node, bgx_idx, lmac, true); > + nic_reg_write(nic, > + NIC_PF_RX_ETYPE_0_7 | (1 << 3), > + (ETYPE_ALG_ENDPARSE << 16) | ETH_P_1588); don't need three lines for this function call. > + } else if (!ptp->enable && pkind->hdr_sl) { > + pkind->maxlen -= (pkind->hdr_sl * 2); > + pkind->hdr_sl = 0; > + bgx_config_timestamping(nic->node, bgx_idx, lmac, false); > + nic_reg_write(nic, > + NIC_PF_RX_ETYPE_0_7 | (1 << 3), > + (1ULL << 16) | ETH_P_8021Q); /* reset value */ here neither. Also avoid comment on the LHS. If 1<<16 means "reset" then just define a macro. > + } > + > + nic_reg_write(nic, NIC_PF_PKIND_0_15_CFG | (pkind_idx << 3), pkind_val); > +} > + Thanks, Richard