* Re: [PATCH v2 0/7] net: ethernet: ti: cpsw: support placing CPDMA descriptors into DDR
From: David Miller @ 2017-01-08 1:48 UTC (permalink / raw)
To: grygorii.strashko
Cc: netdev, mugunthanvnm, ivan.khoronzhuk, nsekhar, linux-kernel,
linux-omap
In-Reply-To: <20170106200735.4210-1-grygorii.strashko@ti.com>
From: Grygorii Strashko <grygorii.strashko@ti.com>
Date: Fri, 6 Jan 2017 14:07:28 -0600
> This series intended to add support for placing CPDMA descriptors into DDR by
> introducing new module parameter "descs_pool_size" to specify size of descriptor's
> pool. The "descs_pool_size" defines total number of CPDMA
> CPPI descriptors to be used for both ingress/egress packets
> processing. If not specified - the default value 256 will be used
> which will allow to place descriptor's pool into the internal CPPI
> RAM.
>
> In addition, added ability to re-split CPDMA pool of descriptors between RX and TX
> path via ethtool '-G' command wich will allow to configure and fix number
> of descriptors used by RX and TX path, which, then, will be split between
> RX/TX channels proportionally depending on number of RX/TX channels and
> its weight.
>
> This allows significantly to reduce UDP packets drop rate
> for bandwidth >301 Mbits/sec (am57x).
>
> Before enabling this feature, the am437x SoC has to be fixed as it's proved
> that it's not working when CPDMA descriptors placed in DDR.
> So, the patch 1 fixes this issue.
Series applied to net-next, thanks.
^ permalink raw reply
* Re: [PATCH v2 net-next 3/4] secure_seq: use SipHash in place of MD5
From: David Miller @ 2017-01-08 1:42 UTC (permalink / raw)
To: ebiggers3
Cc: Jason, jeanphilippe.aumasson, gregkh, netdev, linux-kernel, ak,
David.Laight, tom, hannes, eric.dumazet, luto
In-Reply-To: <20170107220911.GB8327@zzz>
From: Eric Biggers <ebiggers3@gmail.com>
Date: Sat, 7 Jan 2017 14:09:11 -0800
> Well, except those instructions aren't actually used in these
> places. Although x86_64 SHA1-NI accelerated SHA-1 is available in
> the Linux crypto API, it seems that in kernel code it remains
> impractical to use these instructions on small amounts of data
> because they use XMM registers, which means the overhead of
> kernel_fpu_begin()/kernel_fpu_end() must be incurred. Furthermore,
> kernel_fpu_begin() is not allowed in all contexts so there has to be
> a fallback.
>
> Out of curiosity, is this actually a solvable problem, e.g. by
> making the code using the XMM registers responsible for saving and
> restoring the ones clobbered, or by optimizing
> kernel_fpu_begin()/kernel_fpu_end()? Or does it in fact remain
> impractical for such instructions to be used for applications like
> this one?
On x86 making the FPU save more tractible in situations like this is
really hard and will make the code significantly more complex.
It's simpler and cheaper on sparc64, and unlike on x86 there aren't
any fundament restrictions on where FPU stuff can be used. This is
because we don't have "save all the FPU state" instructions and have
to do it all by hand anyways.
However I will note that just like x86, sparc64 doesn't override the
md5_transform() in lib/md5.c like it should.
^ permalink raw reply
* Re: [PATCH v5] net: stmmac: fix maxmtu assignment to be within valid range
From: Andy Shevchenko @ 2017-01-08 1:06 UTC (permalink / raw)
To: Kweh, Hock Leong
Cc: David S. Miller, Joao Pinto, Giuseppe CAVALLARO,
seraphin.bonnaffe, Jarod Wilson, Alexandre TORGUE,
Joachim Eastwood, Niklas Cassel, Johan Hovold, Pavel Machek,
lars.persson, netdev, LKML
In-Reply-To: <1483781523-14334-1-git-send-email-hock.leong.kweh@intel.com>
On Sat, Jan 7, 2017 at 11:32 AM, Kweh, Hock Leong
<hock.leong.kweh@intel.com> wrote:
> From: "Kweh, Hock Leong" <hock.leong.kweh@intel.com>
>
> There is no checking valid value of maxmtu when getting it from
> device tree. This resolution added the checking condition to
> ensure the assignment is made within a valid range.
FWIW:
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
> Signed-off-by: Kweh, Hock Leong <hock.leong.kweh@intel.com>
> ---
> changelog v5:
> * revert back that plat->maxmtu > ndev->max_mtu is a valid case
> when ndev->max_mtu assignment is entering to the else statement
> * add comment to enchance clarification
>
> changelog v4:
> * add print warning message when maxmtu > max_mtu as well
> * add maxmtu = JUMBO_LEN into each *_default_data() at stmmac_pci.c
>
> changelog v3:
> * print the warning message only if maxmtu < min_mtu
> * add maxmtu = JUMBO_LEN at stmmac_pci.c to follow stmmac_platform.c
>
> changelog v2:
> * correction of "devicetree" to "device tree" reported by Andy
> * print warning message while maxmtu is not in valid range
>
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 +++++++++-
> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 6 ++++++
> 2 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 92ac006..8e56dc4 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -3345,8 +3345,16 @@ int stmmac_dvr_probe(struct device *device,
> ndev->max_mtu = JUMBO_LEN;
> else
> ndev->max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN);
> - if (priv->plat->maxmtu < ndev->max_mtu)
> + /* Will not overwrite ndev->max_mtu if plat->maxmtu > ndev->max_mtu
> + * as well as plat->maxmtu < ndev->min_mtu which is a invalid range.
> + */
> + if ((priv->plat->maxmtu < ndev->max_mtu) &&
> + (priv->plat->maxmtu >= ndev->min_mtu))
> ndev->max_mtu = priv->plat->maxmtu;
> + else if (priv->plat->maxmtu < ndev->min_mtu)
> + netdev_warn(priv->dev,
> + "%s: warning: maxmtu having invalid value (%d)\n",
> + __func__, priv->plat->maxmtu);
>
> if (flow_ctrl)
> priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> index a283177..3da4737 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> @@ -89,6 +89,9 @@ static void stmmac_default_data(struct plat_stmmacenet_data *plat)
>
> /* Set default value for unicast filter entries */
> plat->unicast_filter_entries = 1;
> +
> + /* Set the maxmtu to a default of JUMBO_LEN */
> + plat->maxmtu = JUMBO_LEN;
> }
>
> static int quark_default_data(struct plat_stmmacenet_data *plat,
> @@ -126,6 +129,9 @@ static int quark_default_data(struct plat_stmmacenet_data *plat,
> /* Set default value for unicast filter entries */
> plat->unicast_filter_entries = 1;
>
> + /* Set the maxmtu to a default of JUMBO_LEN */
> + plat->maxmtu = JUMBO_LEN;
> +
> return 0;
> }
>
> --
> 1.7.9.5
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* [PATCH net] ipv6: fix typos
From: Alexander Alemayhu @ 2017-01-07 22:53 UTC (permalink / raw)
To: netdev; +Cc: Alexander Alemayhu
o s/approriate/appropriate
o s/discouvery/discovery
Signed-off-by: Alexander Alemayhu <alexander@alemayhu.com>
---
net/ipv6/route.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 8417c41d8ec8..ce5aaf448c54 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1464,7 +1464,7 @@ static struct rt6_info *__ip6_route_redirect(struct net *net,
struct fib6_node *fn;
/* Get the "current" route for this destination and
- * check if the redirect has come from approriate router.
+ * check if the redirect has come from appropriate router.
*
* RFC 4861 specifies that redirects should only be
* accepted if they come from the nexthop to the target.
@@ -2768,7 +2768,7 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)
old MTU is the lowest MTU in the path, update the route PMTU
to reflect the increase. In this case if the other nodes' MTU
also have the lowest MTU, TOO BIG MESSAGE will be lead to
- PMTU discouvery.
+ PMTU discovery.
*/
if (rt->dst.dev == arg->dev &&
dst_metric_raw(&rt->dst, RTAX_MTU) &&
--
2.11.0
^ permalink raw reply related
* Re: [RFC PATCH] intel: Use upper_32_bits and lower_32_bits
From: Julia Lawall @ 2017-01-07 22:20 UTC (permalink / raw)
To: Joe Perches
Cc: Jeff Kirsher, Julia Lawall, intel-wired-lan, netdev, linux-kernel
In-Reply-To: <7a5cfe63cad3ef4badc30cbc2185a5bfb9250fd8.1483813334.git.joe@perches.com>
On Sat, 7 Jan 2017, Joe Perches wrote:
> Shifting and masking various types can be made a bit
> simpler to read by using the available kernel macros.
It looks much nicer to me, especially in the lower case, where there are
multiple ways to express the same thing.
julia
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>
> This RFC patch is meant as an example, not necessarily
> to apply, though it does compile to equivalent code.
>
> It does seem a bit simpler for a human to read.
>
> Perhaps this could be automated via a coccinelle script,
> but this was done with grep & sed and some typing.
>
> Treewide, there are many hundred instances of this style code
> that could be converted.
>
> Dunno if it's really worth it though.
>
> Another usage that could be converted is DMA_BIT_MASK(32)
> where it is equivalent to upper_32_bits and lower_32_bits.
>
> drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 8 ++++----
> drivers/net/ethernet/intel/e1000/e1000_main.c | 8 ++++----
> drivers/net/ethernet/intel/e1000e/ethtool.c | 8 ++++----
> drivers/net/ethernet/intel/fm10k/fm10k_common.c | 4 ++--
> drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 2 +-
> drivers/net/ethernet/intel/i40e/i40e_common.c | 4 ++--
> drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 8 ++++----
> drivers/net/ethernet/intel/i40e/i40e_main.c | 4 ++--
> drivers/net/ethernet/intel/i40e/i40e_ptp.c | 12 ++++++------
> drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 9 +++++----
> drivers/net/ethernet/intel/i40evf/i40evf_main.c | 4 ++--
> drivers/net/ethernet/intel/igb/igb_main.c | 10 ++++------
> drivers/net/ethernet/intel/igb/igb_ptp.c | 4 ++--
> drivers/net/ethernet/intel/ixgb/ixgb_main.c | 12 ++++++------
> drivers/net/ethernet/intel/ixgbe/ixgbe_common.h | 4 ++--
> drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 12 ++++++------
> drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 16 ++++++++--------
> drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 12 ++++++------
> drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c | 4 ++--
> 19 files changed, 72 insertions(+), 73 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
> index 975eeb885ca2..11ad95f34f4f 100644
> --- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
> +++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
> @@ -1021,8 +1021,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
> }
> txdr->next_to_use = txdr->next_to_clean = 0;
>
> - ew32(TDBAL, ((u64)txdr->dma & 0x00000000FFFFFFFF));
> - ew32(TDBAH, ((u64)txdr->dma >> 32));
> + ew32(TDBAL, lower_32_bits(txdr->dma));
> + ew32(TDBAH, upper_32_bits(txdr->dma));
> ew32(TDLEN, txdr->count * sizeof(struct e1000_tx_desc));
> ew32(TDH, 0);
> ew32(TDT, 0);
> @@ -1081,8 +1081,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
>
> rctl = er32(RCTL);
> ew32(RCTL, rctl & ~E1000_RCTL_EN);
> - ew32(RDBAL, ((u64)rxdr->dma & 0xFFFFFFFF));
> - ew32(RDBAH, ((u64)rxdr->dma >> 32));
> + ew32(RDBAL, lower_32_bits(rxdr->dma));
> + ew32(RDBAH, upper_32_bits(rxdr->dma));
> ew32(RDLEN, rxdr->size);
> ew32(RDH, 0);
> ew32(RDT, 0);
> diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
> index 93fc6c67306b..d222f731f280 100644
> --- a/drivers/net/ethernet/intel/e1000/e1000_main.c
> +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
> @@ -1614,8 +1614,8 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
> tdlen = adapter->tx_ring[0].count *
> sizeof(struct e1000_tx_desc);
> ew32(TDLEN, tdlen);
> - ew32(TDBAH, (tdba >> 32));
> - ew32(TDBAL, (tdba & 0x00000000ffffffffULL));
> + ew32(TDBAH, upper_32_bits(tdba));
> + ew32(TDBAL, lower_32_bits(tdba));
> ew32(TDT, 0);
> ew32(TDH, 0);
> adapter->tx_ring[0].tdh = ((hw->mac_type >= e1000_82543) ?
> @@ -1896,8 +1896,8 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
> default:
> rdba = adapter->rx_ring[0].dma;
> ew32(RDLEN, rdlen);
> - ew32(RDBAH, (rdba >> 32));
> - ew32(RDBAL, (rdba & 0x00000000ffffffffULL));
> + ew32(RDBAH, upper_32_bits(rdba));
> + ew32(RDBAL, lower_32_bits(rdba));
> ew32(RDT, 0);
> ew32(RDH, 0);
> adapter->rx_ring[0].rdh = ((hw->mac_type >= e1000_82543) ?
> diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c
> index 7aff68a4a4df..35304b380eaa 100644
> --- a/drivers/net/ethernet/intel/e1000e/ethtool.c
> +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
> @@ -1203,8 +1203,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
> tx_ring->next_to_use = 0;
> tx_ring->next_to_clean = 0;
>
> - ew32(TDBAL(0), ((u64)tx_ring->dma & 0x00000000FFFFFFFF));
> - ew32(TDBAH(0), ((u64)tx_ring->dma >> 32));
> + ew32(TDBAL(0), lower_32_bits(tx_ring->dma));
> + ew32(TDBAH(0), upper_32_bits(tx_ring->dma));
> ew32(TDLEN(0), tx_ring->count * sizeof(struct e1000_tx_desc));
> ew32(TDH(0), 0);
> ew32(TDT(0), 0);
> @@ -1266,8 +1266,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
> rctl = er32(RCTL);
> if (!(adapter->flags2 & FLAG2_NO_DISABLE_RX))
> ew32(RCTL, rctl & ~E1000_RCTL_EN);
> - ew32(RDBAL(0), ((u64)rx_ring->dma & 0xFFFFFFFF));
> - ew32(RDBAH(0), ((u64)rx_ring->dma >> 32));
> + ew32(RDBAL(0), lower_32_bits(rx_ring->dma));
> + ew32(RDBAH(0), upper_32_bits(rx_ring->dma));
> ew32(RDLEN(0), rx_ring->size);
> ew32(RDH(0), 0);
> ew32(RDT(0), 0);
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_common.c b/drivers/net/ethernet/intel/fm10k/fm10k_common.c
> index dd95ac4f4c64..72d428f598b3 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_common.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_common.c
> @@ -325,10 +325,10 @@ static void fm10k_update_hw_base_48b(struct fm10k_hw_stat *stat, u64 delta)
>
> /* update lower 32 bits */
> delta += stat->base_l;
> - stat->base_l = (u32)delta;
> + stat->base_l = lower_32_bits(delta);
>
> /* update upper 32 bits */
> - stat->base_h += (u32)(delta >> 32);
> + stat->base_h += upper_32_bits(delta);
> }
>
> /**
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
> index 23fb319fd2a0..e0cc9883710b 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
> @@ -1548,7 +1548,7 @@ static void fm10k_rebind_hw_stats_pf(struct fm10k_hw *hw,
> static void fm10k_set_dma_mask_pf(struct fm10k_hw *hw, u64 dma_mask)
> {
> /* we need to write the upper 32 bits of DMA mask to PhyAddrSpace */
> - u32 phyaddr = (u32)(dma_mask >> 32);
> + u32 phyaddr = upper_32_bits(dma_mask);
>
> fm10k_write_reg(hw, FM10K_PHYADDR, phyaddr);
> }
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
> index 128735975caa..b184487eb49a 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_common.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
> @@ -2984,8 +2984,8 @@ i40e_status i40e_aq_debug_write_register(struct i40e_hw *hw,
> i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_debug_write_reg);
>
> cmd->address = cpu_to_le32(reg_addr);
> - cmd->value_high = cpu_to_le32((u32)(reg_val >> 32));
> - cmd->value_low = cpu_to_le32((u32)(reg_val & 0xFFFFFFFF));
> + cmd->value_high = cpu_to_le32(upper_32_bits(reg_val));
> + cmd->value_low = cpu_to_le32(lower_32_bits(reg_val));
>
> status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
>
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> index cc1465aac2ef..091ac00053bd 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> @@ -2550,14 +2550,14 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
> flow_pctype)) << 32);
> i_set = i40e_get_rss_hash_bits(nfc, i_setc);
> i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_pctype),
> - (u32)i_set);
> + lower_32_bits(i_set));
> i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_pctype),
> - (u32)(i_set >> 32));
> + upper_32_bits(i_set));
> hena |= BIT_ULL(flow_pctype);
> }
>
> - i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), (u32)hena);
> - i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
> + i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), lower_32_bits(hena));
> + i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), upper_32_bits(hena));
> i40e_flush(hw);
>
> return 0;
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index ad4cf639430e..219c696411f9 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -8410,8 +8410,8 @@ static int i40e_pf_config_rss(struct i40e_pf *pf)
> ((u64)i40e_read_rx_ctl(hw, I40E_PFQF_HENA(1)) << 32);
> hena |= i40e_pf_get_default_rss_hena(pf);
>
> - i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), (u32)hena);
> - i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
> + i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), lower_32_bits(hena));
> + i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), upper_32_bits(hena));
>
> /* Determine the RSS table size based on the hardware capabilities */
> reg_val = i40e_read_rx_ctl(hw, I40E_PFQF_CTL_0);
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> index 9e49ffafce28..b2566ce83505 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
> @@ -88,8 +88,8 @@ static void i40e_ptp_write(struct i40e_pf *pf, const struct timespec64 *ts)
> /* The timer will not update until the high register is written, so
> * write the low register first.
> */
> - wr32(hw, I40E_PRTTSYN_TIME_L, ns & 0xFFFFFFFF);
> - wr32(hw, I40E_PRTTSYN_TIME_H, ns >> 32);
> + wr32(hw, I40E_PRTTSYN_TIME_L, lower_32_bits(ns));
> + wr32(hw, I40E_PRTTSYN_TIME_H, upper_32_bits(ns));
> }
>
> /**
> @@ -141,8 +141,8 @@ static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
> else
> adj += diff;
>
> - wr32(hw, I40E_PRTTSYN_INC_L, adj & 0xFFFFFFFF);
> - wr32(hw, I40E_PRTTSYN_INC_H, adj >> 32);
> + wr32(hw, I40E_PRTTSYN_INC_L, lower_32_bits(adj));
> + wr32(hw, I40E_PRTTSYN_INC_H, upper_32_bits(adj));
>
> return 0;
> }
> @@ -447,8 +447,8 @@ void i40e_ptp_set_increment(struct i40e_pf *pf)
> * hardware will not update the clock until both registers have been
> * written.
> */
> - wr32(hw, I40E_PRTTSYN_INC_L, incval & 0xFFFFFFFF);
> - wr32(hw, I40E_PRTTSYN_INC_H, incval >> 32);
> + wr32(hw, I40E_PRTTSYN_INC_L, lower_32_bits(incval));
> + wr32(hw, I40E_PRTTSYN_INC_H, upper_32_bits(incval));
>
> /* Update the base adjustement value. */
> ACCESS_ONCE(pf->ptp_base_adj) = incval;
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> index 0fb899efbad3..d8cb9aea07a1 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> @@ -705,9 +705,9 @@ static int i40e_alloc_vsi_res(struct i40e_vf *vf, enum i40e_vsi_type type)
> "Could not allocate VF broadcast filter\n");
> spin_unlock_bh(&vsi->mac_filter_hash_lock);
> i40e_write_rx_ctl(&pf->hw, I40E_VFQF_HENA1(0, vf->vf_id),
> - (u32)hena);
> + lower_32_bits(hena));
> i40e_write_rx_ctl(&pf->hw, I40E_VFQF_HENA1(1, vf->vf_id),
> - (u32)(hena >> 32));
> + upper_32_bits(hena));
> }
>
> /* program mac filter */
> @@ -2349,9 +2349,10 @@ static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg, u16 msglen)
> aq_ret = I40E_ERR_PARAM;
> goto err;
> }
> - i40e_write_rx_ctl(hw, I40E_VFQF_HENA1(0, vf->vf_id), (u32)vrh->hena);
> + i40e_write_rx_ctl(hw, I40E_VFQF_HENA1(0, vf->vf_id),
> + lower_32_bits(vrh->hena));
> i40e_write_rx_ctl(hw, I40E_VFQF_HENA1(1, vf->vf_id),
> - (u32)(vrh->hena >> 32));
> + upper_32_bits(vrh->hena));
>
> /* send the response to the VF */
> err:
> diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
> index c0fc53361800..089a1e87ced8 100644
> --- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
> +++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
> @@ -1379,8 +1379,8 @@ static int i40evf_init_rss(struct i40evf_adapter *adapter)
> else
> adapter->hena = I40E_DEFAULT_RSS_HENA;
>
> - wr32(hw, I40E_VFQF_HENA(0), (u32)adapter->hena);
> - wr32(hw, I40E_VFQF_HENA(1), (u32)(adapter->hena >> 32));
> + wr32(hw, I40E_VFQF_HENA(0), lower_32_bits(adapter->hena));
> + wr32(hw, I40E_VFQF_HENA(1), upper_32_bits(adapter->hena));
> }
>
> i40evf_fill_rss_lut(adapter);
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index a761001308dc..a2fd0b6019cf 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -3390,9 +3390,8 @@ void igb_configure_tx_ring(struct igb_adapter *adapter,
>
> wr32(E1000_TDLEN(reg_idx),
> ring->count * sizeof(union e1000_adv_tx_desc));
> - wr32(E1000_TDBAL(reg_idx),
> - tdba & 0x00000000ffffffffULL);
> - wr32(E1000_TDBAH(reg_idx), tdba >> 32);
> + wr32(E1000_TDBAL(reg_idx), lower_32_bits(tdba));
> + wr32(E1000_TDBAH(reg_idx), upper_32_bits(tdba));
>
> ring->tail = hw->hw_addr + E1000_TDT(reg_idx);
> wr32(E1000_TDH(reg_idx), 0);
> @@ -3726,9 +3725,8 @@ void igb_configure_rx_ring(struct igb_adapter *adapter,
> wr32(E1000_RXDCTL(reg_idx), 0);
>
> /* Set DMA base address registers */
> - wr32(E1000_RDBAL(reg_idx),
> - rdba & 0x00000000ffffffffULL);
> - wr32(E1000_RDBAH(reg_idx), rdba >> 32);
> + wr32(E1000_RDBAL(reg_idx), lower_32_bits(rdba));
> + wr32(E1000_RDBAH(reg_idx), upper_32_bits(rdba));
> wr32(E1000_RDLEN(reg_idx),
> ring->count * sizeof(union e1000_adv_rx_desc));
>
> diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
> index c4477552ce9e..67559c73e0e7 100644
> --- a/drivers/net/ethernet/intel/igb/igb_ptp.c
> +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
> @@ -188,8 +188,8 @@ static void igb_ptp_systim_to_hwtstamp(struct igb_adapter *adapter,
> case e1000_i211:
> memset(hwtstamps, 0, sizeof(*hwtstamps));
> /* Upper 32 bits contain s, lower 32 bits contain ns. */
> - hwtstamps->hwtstamp = ktime_set(systim >> 32,
> - systim & 0xFFFFFFFF);
> + hwtstamps->hwtstamp = ktime_set(upper_32_bits(systim),
> + lower_32_bits(systim));
> break;
> default:
> break;
> diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
> index 5826b1ddedcf..a23e99528d5e 100644
> --- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c
> +++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
> @@ -749,8 +749,8 @@ ixgb_configure_tx(struct ixgb_adapter *adapter)
> * tx_ring.dma can be either a 32 or 64 bit value
> */
>
> - IXGB_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
> - IXGB_WRITE_REG(hw, TDBAH, (tdba >> 32));
> + IXGB_WRITE_REG(hw, TDBAL, lower_32_bits(tdba));
> + IXGB_WRITE_REG(hw, TDBAH, upper_32_bits(tdba));
>
> IXGB_WRITE_REG(hw, TDLEN, tdlen);
>
> @@ -875,8 +875,8 @@ ixgb_configure_rx(struct ixgb_adapter *adapter)
>
> /* Setup the Base and Length of the Rx Descriptor Ring */
>
> - IXGB_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
> - IXGB_WRITE_REG(hw, RDBAH, (rdba >> 32));
> + IXGB_WRITE_REG(hw, RDBAL, lower_32_bits(rdba));
> + IXGB_WRITE_REG(hw, RDBAH, upper_32_bits(rdba));
>
> IXGB_WRITE_REG(hw, RDLEN, rdlen);
>
> @@ -1664,8 +1664,8 @@ ixgb_update_stats(struct ixgb_adapter *adapter)
> if (multi >= bcast)
> multi -= bcast;
>
> - adapter->stats.mprcl += (multi & 0xFFFFFFFF);
> - adapter->stats.mprch += (multi >> 32);
> + adapter->stats.mprcl += lower_32_bits(multi);
> + adapter->stats.mprch += upper_32_bits(multi);
> adapter->stats.bprcl += bcast_l;
> adapter->stats.bprch += bcast_h;
> } else {
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
> index e083732adf64..6237e6c2ed30 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
> @@ -173,8 +173,8 @@ static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
> #define writeq writeq
> static inline void writeq(u64 val, void __iomem *addr)
> {
> - writel((u32)val, addr);
> - writel((u32)(val >> 32), addr + 4);
> + writel(lower_32_bits(val), addr);
> + writel(upper_32_bits(val), addr + 4);
> }
> #endif
>
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> index 17589068da78..0d973e2d0937 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> @@ -748,10 +748,10 @@ static void ixgbe_get_regs(struct net_device *netdev,
> regs_buff[939] = IXGBE_GET_STAT(adapter, bprc);
> regs_buff[940] = IXGBE_GET_STAT(adapter, mprc);
> regs_buff[941] = IXGBE_GET_STAT(adapter, gptc);
> - regs_buff[942] = (u32)IXGBE_GET_STAT(adapter, gorc);
> - regs_buff[943] = (u32)(IXGBE_GET_STAT(adapter, gorc) >> 32);
> - regs_buff[944] = (u32)IXGBE_GET_STAT(adapter, gotc);
> - regs_buff[945] = (u32)(IXGBE_GET_STAT(adapter, gotc) >> 32);
> + regs_buff[942] = lower_32_bits(IXGBE_GET_STAT(adapter, gorc));
> + regs_buff[943] = upper_32_bits(IXGBE_GET_STAT(adapter, gorc));
> + regs_buff[944] = lower_32_bits(IXGBE_GET_STAT(adapter, gotc));
> + regs_buff[945] = upper_32_bits(IXGBE_GET_STAT(adapter, gotc));
> for (i = 0; i < 8; i++)
> regs_buff[946 + i] = IXGBE_GET_STAT(adapter, rnbc[i]);
> regs_buff[954] = IXGBE_GET_STAT(adapter, ruc);
> @@ -761,8 +761,8 @@ static void ixgbe_get_regs(struct net_device *netdev,
> regs_buff[958] = IXGBE_GET_STAT(adapter, mngprc);
> regs_buff[959] = IXGBE_GET_STAT(adapter, mngpdc);
> regs_buff[960] = IXGBE_GET_STAT(adapter, mngptc);
> - regs_buff[961] = (u32)IXGBE_GET_STAT(adapter, tor);
> - regs_buff[962] = (u32)(IXGBE_GET_STAT(adapter, tor) >> 32);
> + regs_buff[961] = lower_32_bits(IXGBE_GET_STAT(adapter, tor));
> + regs_buff[962] = upper_32_bits(IXGBE_GET_STAT(adapter, tor));
> regs_buff[963] = IXGBE_GET_STAT(adapter, tpr);
> regs_buff[964] = IXGBE_GET_STAT(adapter, tpt);
> regs_buff[965] = IXGBE_GET_STAT(adapter, ptc64);
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> index 0c6eca570791..71d054f6a2aa 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> @@ -936,10 +936,10 @@ static inline void ixgbe_irq_rearm_queues(struct ixgbe_adapter *adapter,
> case ixgbe_mac_X550:
> case ixgbe_mac_X550EM_x:
> case ixgbe_mac_x550em_a:
> - mask = (qmask & 0xFFFFFFFF);
> - IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(0), mask);
> - mask = (qmask >> 32);
> - IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(1), mask);
> + IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(0),
> + lower_32_bits(qmask));
> + IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(1),
> + upper_32_bits(qmask));
> break;
> default:
> break;
> @@ -2650,10 +2650,10 @@ static inline void ixgbe_irq_enable_queues(struct ixgbe_adapter *adapter,
> case ixgbe_mac_X550:
> case ixgbe_mac_X550EM_x:
> case ixgbe_mac_x550em_a:
> - mask = (qmask & 0xFFFFFFFF);
> + mask = lower_32_bits(qmask);
> if (mask)
> IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
> - mask = (qmask >> 32);
> + mask = upper_32_bits(qmask);
> if (mask)
> IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
> break;
> @@ -2679,10 +2679,10 @@ static inline void ixgbe_irq_disable_queues(struct ixgbe_adapter *adapter,
> case ixgbe_mac_X550:
> case ixgbe_mac_X550EM_x:
> case ixgbe_mac_x550em_a:
> - mask = (qmask & 0xFFFFFFFF);
> + mask = lower_32_bits(qmask);
> if (mask)
> IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), mask);
> - mask = (qmask >> 32);
> + mask = upper_32_bits(qmask);
> if (mask)
> IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), mask);
> break;
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
> index ef0635e0918c..a1cb0b99456c 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
> @@ -206,8 +206,8 @@ static void ixgbe_ptp_setup_sdp_x540(struct ixgbe_adapter *adapter)
> IXGBE_TSAUXC_SDP0_INT;
>
> /* clock period (or pulse length) */
> - clktiml = (u32)(IXGBE_PTP_PPS_HALF_SECOND << shift);
> - clktimh = (u32)((IXGBE_PTP_PPS_HALF_SECOND << shift) >> 32);
> + clktiml = lower_32_bits(IXGBE_PTP_PPS_HALF_SECOND << shift);
> + clktimh = upper_32_bits(IXGBE_PTP_PPS_HALF_SECOND << shift);
>
> /* Account for the cyclecounter wrap-around value by
> * using the converted ns value of the current time to
> @@ -221,8 +221,8 @@ static void ixgbe_ptp_setup_sdp_x540(struct ixgbe_adapter *adapter)
> clock_edge += ((IXGBE_PTP_PPS_HALF_SECOND - (u64)rem) << shift);
>
> /* specify the initial clock start time */
> - trgttiml = (u32)clock_edge;
> - trgttimh = (u32)(clock_edge >> 32);
> + trgttiml = lower_32_bits(clock_edge);
> + trgttimh = upper_32_bits(clock_edge);
>
> IXGBE_WRITE_REG(hw, IXGBE_CLKTIML, clktiml);
> IXGBE_WRITE_REG(hw, IXGBE_CLKTIMH, clktimh);
> @@ -339,8 +339,8 @@ static void ixgbe_ptp_convert_to_hwtstamp(struct ixgbe_adapter *adapter,
> * correct math even though the units haven't been corrected
> * yet.
> */
> - systime.tv_sec = timestamp >> 32;
> - systime.tv_nsec = timestamp & 0xFFFFFFFF;
> + systime.tv_sec = upper_32_bits(timestamp);
> + systime.tv_nsec = lower_32_bits(timestamp);
>
> timestamp = timespec64_to_ns(&systime);
> break;
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
> index 200f847fd8f3..1d3ca7a5106f 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
> @@ -3437,8 +3437,8 @@ static void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw,
> else
> pfflp &= ~(1ULL << pool);
>
> - IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
> - IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
> + IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, lower_32_bits(pfflp));
> + IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, upper_32_bits(pfflp));
> }
>
> /**
> --
> 2.10.0.rc2.1.g053435c
>
>
^ permalink raw reply
* [PATCH] net: intel: e100: use new api ethtool_{get|set}_link_ksettings
From: Philippe Reynes @ 2017-01-07 22:18 UTC (permalink / raw)
To: jeffrey.t.kirsher, davem
Cc: intel-wired-lan, netdev, linux-kernel, Philippe Reynes
The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.
Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
drivers/net/ethernet/intel/e100.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index 25c6dfd..04e9392 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -2426,19 +2426,21 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
#define E100_82552_LED_ON 0x000F /* LEDTX and LED_RX both on */
#define E100_82552_LED_OFF 0x000A /* LEDTX and LED_RX both off */
-static int e100_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
+static int e100_get_link_ksettings(struct net_device *netdev,
+ struct ethtool_link_ksettings *cmd)
{
struct nic *nic = netdev_priv(netdev);
- return mii_ethtool_gset(&nic->mii, cmd);
+ return mii_ethtool_get_link_ksettings(&nic->mii, cmd);
}
-static int e100_set_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
+static int e100_set_link_ksettings(struct net_device *netdev,
+ const struct ethtool_link_ksettings *cmd)
{
struct nic *nic = netdev_priv(netdev);
int err;
mdio_write(netdev, nic->mii.phy_id, MII_BMCR, BMCR_RESET);
- err = mii_ethtool_sset(&nic->mii, cmd);
+ err = mii_ethtool_set_link_ksettings(&nic->mii, cmd);
e100_exec_cb(nic, NULL, e100_configure);
return err;
@@ -2741,8 +2743,6 @@ static void e100_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
}
static const struct ethtool_ops e100_ethtool_ops = {
- .get_settings = e100_get_settings,
- .set_settings = e100_set_settings,
.get_drvinfo = e100_get_drvinfo,
.get_regs_len = e100_get_regs_len,
.get_regs = e100_get_regs,
@@ -2763,6 +2763,8 @@ static void e100_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
.get_ethtool_stats = e100_get_ethtool_stats,
.get_sset_count = e100_get_sset_count,
.get_ts_info = ethtool_op_get_ts_info,
+ .get_link_ksettings = e100_get_link_ksettings,
+ .set_link_ksettings = e100_set_link_ksettings,
};
static int e100_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
--
1.7.4.4
^ permalink raw reply related
* Re: [PATCH v2 net-next 3/4] secure_seq: use SipHash in place of MD5
From: Eric Biggers @ 2017-01-07 22:09 UTC (permalink / raw)
To: David Miller
Cc: Jason, jeanphilippe.aumasson, gregkh, netdev, linux-kernel, ak,
David.Laight, tom, hannes, eric.dumazet, luto
In-Reply-To: <20170107.163736.2224609477435674963.davem@davemloft.net>
Hi David,
On Sat, Jan 07, 2017 at 04:37:36PM -0500, David Miller wrote:
> From: "Jason A. Donenfeld" <Jason@zx2c4.com>
> Date: Sat, 7 Jan 2017 15:40:56 +0100
>
> > This gives a clear speed and security improvement. Siphash is both
> > faster and is more solid crypto than the aging MD5.
[snip]
>
> This and the next patch are a real shame, performance wise, on cpus
> that have single-instruction SHA1 and MD5 implementations. Sparc64
> has both, and I believe x86_64 can do SHA1 these days.
>
> It took so long to get those instructions into real silicon, and then
> have software implemented to make use of them as well.
>
> Who knows when we'll see SipHash widely deployed in any instruction
> set, if at all, right? And by that time we'll possibly find out that
> "Oh shit, this SipHash thing has flaws!" and we'll need
> DIPPY_DO_DA_HASH and thus be forced back to a software implementation
> again.
>
> I understand the reasons why these patches are being proposed, I just
> thought I'd mention the issue of cpus that implement secure hash
> algorithm instructions.
Well, except those instructions aren't actually used in these places. Although
x86_64 SHA1-NI accelerated SHA-1 is available in the Linux crypto API, it seems
that in kernel code it remains impractical to use these instructions on small
amounts of data because they use XMM registers, which means the overhead of
kernel_fpu_begin()/kernel_fpu_end() must be incurred. Furthermore,
kernel_fpu_begin() is not allowed in all contexts so there has to be a fallback.
Out of curiosity, is this actually a solvable problem, e.g. by making the code
using the XMM registers responsible for saving and restoring the ones clobbered,
or by optimizing kernel_fpu_begin()/kernel_fpu_end()? Or does it in fact remain
impractical for such instructions to be used for applications like this one?
Eric
^ permalink raw reply
* [PATCH net-next 6/6] net-tc: convert tc_from to tc_from_ingress and tc_redirected
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
To: netdev
Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
Willem de Bruijn
In-Reply-To: <20170107220638.61314-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
The tc_from field fulfills two roles. It encodes whether a packet was
redirected by an act_mirred device and, if so, whether act_mirred was
called on ingress or egress. Split it into separate fields.
The information is needed by the special IFB loop, where packets are
taken out of the normal path by act_mirred, forwarded to IFB, then
reinjected at their original location (ingress or egress) by IFB.
The IFB device cannot use skb->tc_at_ingress, because that may have
been overwritten as the packet travels from act_mirred to ifb_xmit,
when it passes through tc_classify on the IFB egress path. Cache this
value in skb->tc_from_ingress.
That field is valid only if a packet arriving at ifb_xmit came from
act_mirred. Other packets can be crafted to reach ifb_xmit. These
must be dropped. Set tc_redirected on redirection and drop all packets
that do not have this bit set.
Both fields are set only on cloned skbs in tc actions, so original
packet sources do not have to clear the bit when reusing packets
(notably, pktgen and octeon).
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
drivers/net/ifb.c | 13 +++++--------
include/linux/skbuff.h | 5 ++++-
include/net/sch_generic.h | 2 +-
include/uapi/linux/pkt_cls.h | 6 ------
net/sched/act_mirred.c | 6 ++++--
net/sched/sch_netem.c | 2 +-
6 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 90ad8791bc99..193af7483bb0 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -78,9 +78,7 @@ static void ifb_ri_tasklet(unsigned long _txp)
}
while ((skb = __skb_dequeue(&txp->tq)) != NULL) {
- u32 from = skb->tc_from;
-
- skb_reset_tc(skb);
+ skb->tc_redirected = 0;
skb->tc_skip_classify = 1;
u64_stats_update_begin(&txp->tsync);
@@ -101,13 +99,12 @@ static void ifb_ri_tasklet(unsigned long _txp)
rcu_read_unlock();
skb->skb_iif = txp->dev->ifindex;
- if (from & AT_EGRESS) {
+ if (!skb->tc_from_ingress) {
dev_queue_xmit(skb);
- } else if (from & AT_INGRESS) {
+ } else {
skb_pull(skb, skb->mac_len);
netif_receive_skb(skb);
- } else
- BUG();
+ }
}
if (__netif_tx_trylock(txq)) {
@@ -248,7 +245,7 @@ static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev)
txp->rx_bytes += skb->len;
u64_stats_update_end(&txp->rsync);
- if (skb->tc_from == AT_STACK || !skb->skb_iif) {
+ if (!skb->tc_redirected || !skb->skb_iif) {
dev_kfree_skb(skb);
dev->stats.rx_dropped++;
return NETDEV_TX_OK;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index fab3f87e9bd1..3149a88de548 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -591,6 +591,8 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1,
* @ipvs_property: skbuff is owned by ipvs
* @tc_skip_classify: do not classify packet. set by IFB device
* @tc_at_ingress: used within tc_classify to distinguish in/egress
+ * @tc_redirected: packet was redirected by a tc action
+ * @tc_from_ingress: if tc_redirected, tc_at_ingress at time of redirect
* @peeked: this packet has been seen already, so stats have been
* done for it, don't do them again
* @nf_trace: netfilter packet trace flag
@@ -753,7 +755,8 @@ struct sk_buff {
#ifdef CONFIG_NET_CLS_ACT
__u8 tc_skip_classify:1;
__u8 tc_at_ingress:1;
- __u8 tc_from:2;
+ __u8 tc_redirected:1;
+ __u8 tc_from_ingress:1;
#endif
#ifdef CONFIG_NET_SCHED
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 4bd6d5387209..e2f426f6d62f 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -412,7 +412,7 @@ int skb_do_redirect(struct sk_buff *);
static inline void skb_reset_tc(struct sk_buff *skb)
{
#ifdef CONFIG_NET_CLS_ACT
- skb->tc_from = 0;
+ skb->tc_redirected = 0;
#endif
}
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index cee753a7a40c..a081efbd61a2 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -4,12 +4,6 @@
#include <linux/types.h>
#include <linux/pkt_sched.h>
-#ifdef __KERNEL__
-#define AT_STACK 0x0
-#define AT_INGRESS 0x1
-#define AT_EGRESS 0x2
-#endif
-
/* Action attributes */
enum {
TCA_ACT_UNSPEC,
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index e832c62fd705..84682f02b611 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -211,8 +211,10 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
}
/* mirror is always swallowed */
- if (tcf_mirred_is_act_redirect(m_eaction))
- skb2->tc_from = skb_at_tc_ingress(skb) ? AT_INGRESS : AT_EGRESS;
+ if (tcf_mirred_is_act_redirect(m_eaction)) {
+ skb2->tc_redirected = 1;
+ skb2->tc_from_ingress = skb2->tc_at_ingress;
+ }
skb2->skb_iif = skb->dev->ifindex;
skb2->dev = dev;
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index bb5c638b6852..c8bb62a1e744 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -626,7 +626,7 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
* If it's at ingress let's pretend the delay is
* from the network (tstamp will be updated).
*/
- if (skb->tc_from & AT_INGRESS)
+ if (skb->tc_redirected && skb->tc_from_ingress)
skb->tstamp = 0;
#endif
--
2.11.0.390.gc69c2f50cf-goog
^ permalink raw reply related
* [PATCH net-next 5/6] net-tc: convert tc_at to tc_at_ingress
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
To: netdev
Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
Willem de Bruijn
In-Reply-To: <20170107220638.61314-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
Field tc_at is used only within tc actions to distinguish ingress from
egress processing. A single bit is sufficient for this purpose.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
include/linux/skbuff.h | 3 ++-
include/net/sch_generic.h | 3 +--
net/core/dev.c | 8 +++-----
net/sched/act_mirred.c | 12 ++++++------
4 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index f738d09947b2..fab3f87e9bd1 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -590,6 +590,7 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1,
* @fclone: skbuff clone status
* @ipvs_property: skbuff is owned by ipvs
* @tc_skip_classify: do not classify packet. set by IFB device
+ * @tc_at_ingress: used within tc_classify to distinguish in/egress
* @peeked: this packet has been seen already, so stats have been
* done for it, don't do them again
* @nf_trace: netfilter packet trace flag
@@ -751,7 +752,7 @@ struct sk_buff {
#endif
#ifdef CONFIG_NET_CLS_ACT
__u8 tc_skip_classify:1;
- __u8 tc_at:2;
+ __u8 tc_at_ingress:1;
__u8 tc_from:2;
#endif
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index f80dba516964..4bd6d5387209 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -412,7 +412,6 @@ int skb_do_redirect(struct sk_buff *);
static inline void skb_reset_tc(struct sk_buff *skb)
{
#ifdef CONFIG_NET_CLS_ACT
- skb->tc_at = 0;
skb->tc_from = 0;
#endif
}
@@ -420,7 +419,7 @@ static inline void skb_reset_tc(struct sk_buff *skb)
static inline bool skb_at_tc_ingress(const struct sk_buff *skb)
{
#ifdef CONFIG_NET_CLS_ACT
- return skb->tc_at & AT_INGRESS;
+ return skb->tc_at_ingress;
#else
return false;
#endif
diff --git a/net/core/dev.c b/net/core/dev.c
index 8b5d6d033473..c143f1391117 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3153,9 +3153,7 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)
if (!cl)
return skb;
- /* skb->tc_at and qdisc_skb_cb(skb)->pkt_len were already set
- * earlier by the caller.
- */
+ /* qdisc_skb_cb(skb)->pkt_len was already set by the caller. */
qdisc_bstats_cpu_update(cl->q, skb);
switch (tc_classify(skb, cl, &cl_res, false)) {
@@ -3320,7 +3318,7 @@ static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
qdisc_pkt_len_init(skb);
#ifdef CONFIG_NET_CLS_ACT
- skb->tc_at = AT_EGRESS;
+ skb->tc_at_ingress = 0;
# ifdef CONFIG_NET_EGRESS
if (static_key_false(&egress_needed)) {
skb = sch_handle_egress(skb, &rc, dev);
@@ -3920,7 +3918,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
}
qdisc_skb_cb(skb)->pkt_len = skb->len;
- skb->tc_at = AT_INGRESS;
+ skb->tc_at_ingress = 1;
qdisc_bstats_cpu_update(cl->q, skb);
switch (tc_classify(skb, cl, &cl_res, false)) {
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 8543279bba49..e832c62fd705 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -39,15 +39,15 @@ static bool tcf_mirred_is_act_redirect(int action)
return action == TCA_EGRESS_REDIR || action == TCA_INGRESS_REDIR;
}
-static u32 tcf_mirred_act_direction(int action)
+static bool tcf_mirred_act_wants_ingress(int action)
{
switch (action) {
case TCA_EGRESS_REDIR:
case TCA_EGRESS_MIRROR:
- return AT_EGRESS;
+ return false;
case TCA_INGRESS_REDIR:
case TCA_INGRESS_MIRROR:
- return AT_INGRESS;
+ return true;
default:
BUG();
}
@@ -198,7 +198,7 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
* and devices expect a mac header on xmit, then mac push/pull is
* needed.
*/
- if (skb->tc_at != tcf_mirred_act_direction(m_eaction) &&
+ if (skb_at_tc_ingress(skb) != tcf_mirred_act_wants_ingress(m_eaction) &&
m_mac_header_xmit) {
if (!skb_at_tc_ingress(skb)) {
/* caught at egress, act ingress: pull mac */
@@ -212,11 +212,11 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
/* mirror is always swallowed */
if (tcf_mirred_is_act_redirect(m_eaction))
- skb2->tc_from = skb2->tc_at;
+ skb2->tc_from = skb_at_tc_ingress(skb) ? AT_INGRESS : AT_EGRESS;
skb2->skb_iif = skb->dev->ifindex;
skb2->dev = dev;
- if (tcf_mirred_act_direction(m_eaction) & AT_EGRESS)
+ if (!tcf_mirred_act_wants_ingress(m_eaction))
err = dev_queue_xmit(skb2);
else
err = netif_receive_skb(skb2);
--
2.11.0.390.gc69c2f50cf-goog
^ permalink raw reply related
* [PATCH net-next 4/6] net-tc: convert tc_verd to integer bitfields
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
To: netdev
Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
Willem de Bruijn
In-Reply-To: <20170107220638.61314-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
Extract the remaining two fields from tc_verd and remove the __u16
completely. TC_AT and TC_FROM are converted to equivalent two-bit
integer fields tc_at and tc_from. Where possible, use existing
helper skb_at_tc_ingress when reading tc_at. Introduce helper
skb_reset_tc to clear fields.
Not documenting tc_from and tc_at, because they will be replaced
with single bit fields in follow-on patches.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
drivers/net/ifb.c | 7 +++----
drivers/staging/octeon/ethernet-tx.c | 5 ++---
include/linux/skbuff.h | 6 ++----
include/net/sch_generic.h | 10 +++++++++-
include/uapi/linux/pkt_cls.h | 31 -------------------------------
net/core/dev.c | 10 ++++------
net/core/pktgen.c | 4 +---
net/core/skbuff.c | 3 ---
net/sched/act_ife.c | 7 +++----
net/sched/act_mirred.c | 9 ++++-----
net/sched/sch_netem.c | 2 +-
11 files changed, 29 insertions(+), 65 deletions(-)
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 4299ac163376..90ad8791bc99 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -78,9 +78,9 @@ static void ifb_ri_tasklet(unsigned long _txp)
}
while ((skb = __skb_dequeue(&txp->tq)) != NULL) {
- u32 from = G_TC_FROM(skb->tc_verd);
+ u32 from = skb->tc_from;
- skb->tc_verd = 0;
+ skb_reset_tc(skb);
skb->tc_skip_classify = 1;
u64_stats_update_begin(&txp->tsync);
@@ -241,7 +241,6 @@ static void ifb_setup(struct net_device *dev)
static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct ifb_dev_private *dp = netdev_priv(dev);
- u32 from = G_TC_FROM(skb->tc_verd);
struct ifb_q_private *txp = dp->tx_private + skb_get_queue_mapping(skb);
u64_stats_update_begin(&txp->rsync);
@@ -249,7 +248,7 @@ static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev)
txp->rx_bytes += skb->len;
u64_stats_update_end(&txp->rsync);
- if (!(from & (AT_INGRESS|AT_EGRESS)) || !skb->skb_iif) {
+ if (skb->tc_from == AT_STACK || !skb->skb_iif) {
dev_kfree_skb(skb);
dev->stats.rx_dropped++;
return NETDEV_TX_OK;
diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c
index 6b4c20872323..0b8053205091 100644
--- a/drivers/staging/octeon/ethernet-tx.c
+++ b/drivers/staging/octeon/ethernet-tx.c
@@ -23,6 +23,7 @@
#endif /* CONFIG_XFRM */
#include <linux/atomic.h>
+#include <net/sch_generic.h>
#include <asm/octeon/octeon.h>
@@ -369,9 +370,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
#ifdef CONFIG_NET_SCHED
skb->tc_index = 0;
-#ifdef CONFIG_NET_CLS_ACT
- skb->tc_verd = 0;
-#endif /* CONFIG_NET_CLS_ACT */
+ skb_reset_tc(skb);
#endif /* CONFIG_NET_SCHED */
#endif /* REUSE_SKBUFFS_WITHOUT_FREE */
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 570f60ec6cb4..f738d09947b2 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -599,7 +599,6 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1,
* @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
* @skb_iif: ifindex of device we arrived on
* @tc_index: Traffic control index
- * @tc_verd: traffic control verdict
* @hash: the packet hash
* @queue_mapping: Queue mapping for multiqueue devices
* @xmit_more: More SKBs are pending for this queue
@@ -752,13 +751,12 @@ struct sk_buff {
#endif
#ifdef CONFIG_NET_CLS_ACT
__u8 tc_skip_classify:1;
+ __u8 tc_at:2;
+ __u8 tc_from:2;
#endif
#ifdef CONFIG_NET_SCHED
__u16 tc_index; /* traffic control index */
-#ifdef CONFIG_NET_CLS_ACT
- __u16 tc_verd; /* traffic control verdict */
-#endif
#endif
union {
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 857356f2d74b..f80dba516964 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -409,10 +409,18 @@ bool tcf_destroy(struct tcf_proto *tp, bool force);
void tcf_destroy_chain(struct tcf_proto __rcu **fl);
int skb_do_redirect(struct sk_buff *);
+static inline void skb_reset_tc(struct sk_buff *skb)
+{
+#ifdef CONFIG_NET_CLS_ACT
+ skb->tc_at = 0;
+ skb->tc_from = 0;
+#endif
+}
+
static inline bool skb_at_tc_ingress(const struct sk_buff *skb)
{
#ifdef CONFIG_NET_CLS_ACT
- return G_TC_AT(skb->tc_verd) & AT_INGRESS;
+ return skb->tc_at & AT_INGRESS;
#else
return false;
#endif
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index 1eed5d7509bc..cee753a7a40c 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -5,40 +5,9 @@
#include <linux/pkt_sched.h>
#ifdef __KERNEL__
-/* I think i could have done better macros ; for now this is stolen from
- * some arch/mips code - jhs
-*/
-#define _TC_MAKE32(x) ((x))
-
-#define _TC_MAKEMASK1(n) (_TC_MAKE32(1) << _TC_MAKE32(n))
-#define _TC_MAKEMASK(v,n) (_TC_MAKE32((_TC_MAKE32(1)<<(v))-1) << _TC_MAKE32(n))
-#define _TC_MAKEVALUE(v,n) (_TC_MAKE32(v) << _TC_MAKE32(n))
-#define _TC_GETVALUE(v,n,m) ((_TC_MAKE32(v) & _TC_MAKE32(m)) >> _TC_MAKE32(n))
-
-/* verdict bit breakdown
- *
-bit 6,7: Where this packet was last seen
-0: Above the transmit example at the socket level
-1: on the Ingress
-2: on the Egress
-
- *
- * */
-
-#define S_TC_FROM _TC_MAKE32(6)
-#define M_TC_FROM _TC_MAKEMASK(2,S_TC_FROM)
-#define G_TC_FROM(x) _TC_GETVALUE(x,S_TC_FROM,M_TC_FROM)
-#define V_TC_FROM(x) _TC_MAKEVALUE(x,S_TC_FROM)
-#define SET_TC_FROM(v,n) ((V_TC_FROM(n)) | (v & ~M_TC_FROM))
#define AT_STACK 0x0
#define AT_INGRESS 0x1
#define AT_EGRESS 0x2
-
-#define S_TC_AT _TC_MAKE32(12)
-#define M_TC_AT _TC_MAKEMASK(2,S_TC_AT)
-#define G_TC_AT(x) _TC_GETVALUE(x,S_TC_AT,M_TC_AT)
-#define V_TC_AT(x) _TC_MAKEVALUE(x,S_TC_AT)
-#define SET_TC_AT(v,n) ((V_TC_AT(n)) | (v & ~M_TC_AT))
#endif
/* Action attributes */
diff --git a/net/core/dev.c b/net/core/dev.c
index e39e35d2e082..8b5d6d033473 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3153,7 +3153,7 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)
if (!cl)
return skb;
- /* skb->tc_verd and qdisc_skb_cb(skb)->pkt_len were already set
+ /* skb->tc_at and qdisc_skb_cb(skb)->pkt_len were already set
* earlier by the caller.
*/
qdisc_bstats_cpu_update(cl->q, skb);
@@ -3320,7 +3320,7 @@ static int __dev_queue_xmit(struct sk_buff *skb, void *accel_priv)
qdisc_pkt_len_init(skb);
#ifdef CONFIG_NET_CLS_ACT
- skb->tc_verd = SET_TC_AT(skb->tc_verd, AT_EGRESS);
+ skb->tc_at = AT_EGRESS;
# ifdef CONFIG_NET_EGRESS
if (static_key_false(&egress_needed)) {
skb = sch_handle_egress(skb, &rc, dev);
@@ -3920,7 +3920,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
}
qdisc_skb_cb(skb)->pkt_len = skb->len;
- skb->tc_verd = SET_TC_AT(skb->tc_verd, AT_INGRESS);
+ skb->tc_at = AT_INGRESS;
qdisc_bstats_cpu_update(cl->q, skb);
switch (tc_classify(skb, cl, &cl_res, false)) {
@@ -4122,9 +4122,7 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
goto out;
}
#endif
-#ifdef CONFIG_NET_CLS_ACT
- skb->tc_verd = 0;
-#endif
+ skb_reset_tc(skb);
skip_classify:
if (pfmemalloc && !skb_pfmemalloc_protocol(skb))
goto drop;
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 8e69ce472236..96947f5d41e4 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3439,9 +3439,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
/* skb was 'freed' by stack, so clean few
* bits and reuse it
*/
-#ifdef CONFIG_NET_CLS_ACT
- skb->tc_verd = 0; /* reset reclass/redir ttl */
-#endif
+ skb_reset_tc(skb);
} while (--burst > 0);
goto out; /* Skips xmit_mode M_START_XMIT */
} else if (pkt_dev->xmit_mode == M_QUEUE_XMIT) {
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 5a03730fbc1a..adec4bf807d8 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -878,9 +878,6 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
#endif
#ifdef CONFIG_NET_SCHED
CHECK_SKB_FIELD(tc_index);
-#ifdef CONFIG_NET_CLS_ACT
- CHECK_SKB_FIELD(tc_verd);
-#endif
#endif
}
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index 80b848d3f096..921fb20eaa7c 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -736,12 +736,11 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,
u16 metalen = ife_get_sz(skb, ife);
int hdrm = metalen + skb->dev->hard_header_len + IFE_METAHDRLEN;
unsigned int skboff = skb->dev->hard_header_len;
- u32 at = G_TC_AT(skb->tc_verd);
int new_len = skb->len + hdrm;
bool exceed_mtu = false;
int err;
- if (at & AT_EGRESS) {
+ if (!skb_at_tc_ingress(skb)) {
if (new_len > skb->dev->mtu)
exceed_mtu = true;
}
@@ -773,7 +772,7 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,
return TC_ACT_SHOT;
}
- if (!(at & AT_EGRESS))
+ if (skb_at_tc_ingress(skb))
skb_push(skb, skb->dev->hard_header_len);
iethh = (struct ethhdr *)skb->data;
@@ -816,7 +815,7 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,
ether_addr_copy(oethh->h_dest, iethh->h_dest);
oethh->h_proto = htons(ife->eth_type);
- if (!(at & AT_EGRESS))
+ if (skb_at_tc_ingress(skb))
skb_pull(skb, skb->dev->hard_header_len);
spin_unlock(&ife->tcf_lock);
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 2d9fa6e0a1b4..8543279bba49 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -170,7 +170,6 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
int retval, err = 0;
int m_eaction;
int mac_len;
- u32 at;
tcf_lastuse_update(&m->tcf_tm);
bstats_cpu_update(this_cpu_ptr(m->common.cpu_bstats), skb);
@@ -191,7 +190,6 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
goto out;
}
- at = G_TC_AT(skb->tc_verd);
skb2 = skb_clone(skb, GFP_ATOMIC);
if (!skb2)
goto out;
@@ -200,8 +198,9 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
* and devices expect a mac header on xmit, then mac push/pull is
* needed.
*/
- if (at != tcf_mirred_act_direction(m_eaction) && m_mac_header_xmit) {
- if (at & AT_EGRESS) {
+ if (skb->tc_at != tcf_mirred_act_direction(m_eaction) &&
+ m_mac_header_xmit) {
+ if (!skb_at_tc_ingress(skb)) {
/* caught at egress, act ingress: pull mac */
mac_len = skb_network_header(skb) - skb_mac_header(skb);
skb_pull_rcsum(skb2, mac_len);
@@ -213,7 +212,7 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
/* mirror is always swallowed */
if (tcf_mirred_is_act_redirect(m_eaction))
- skb2->tc_verd = SET_TC_FROM(skb2->tc_verd, at);
+ skb2->tc_from = skb2->tc_at;
skb2->skb_iif = skb->dev->ifindex;
skb2->dev = dev;
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index bcfadfdea8e0..bb5c638b6852 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -626,7 +626,7 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
* If it's at ingress let's pretend the delay is
* from the network (tstamp will be updated).
*/
- if (G_TC_FROM(skb->tc_verd) & AT_INGRESS)
+ if (skb->tc_from & AT_INGRESS)
skb->tstamp = 0;
#endif
--
2.11.0.390.gc69c2f50cf-goog
^ permalink raw reply related
* [PATCH net-next 3/6] net-tc: extract skip classify bit from tc_verd
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
To: netdev
Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
Willem de Bruijn
In-Reply-To: <20170107220638.61314-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
Packets sent by the IFB device skip subsequent tc classification.
A single bit governs this state. Move it out of tc_verd in
anticipation of removing that __u16 completely.
The new bitfield tc_skip_classify temporarily uses one bit of a
hole, until tc_verd is removed completely in a follow-up patch.
Remove the bit hole comment. It could be 2, 3, 4 or 5 bits long.
With that many options, little value in documenting it.
Introduce a helper function to deduplicate the logic in the two
sites that check this bit.
The field tc_skip_classify is set only in IFB on skbs cloned in
act_mirred, so original packet sources do not have to clear the
bit when reusing packets (notably, pktgen and octeon).
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
drivers/net/ifb.c | 2 +-
include/linux/skbuff.h | 5 ++++-
include/net/sch_generic.h | 11 +++++++++++
include/uapi/linux/pkt_cls.h | 6 ------
net/core/dev.c | 10 +++-------
net/sched/act_api.c | 11 ++++-------
6 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 66c0eeafcb5d..4299ac163376 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -81,7 +81,7 @@ static void ifb_ri_tasklet(unsigned long _txp)
u32 from = G_TC_FROM(skb->tc_verd);
skb->tc_verd = 0;
- skb->tc_verd = SET_TC_NCLS(skb->tc_verd);
+ skb->tc_skip_classify = 1;
u64_stats_update_begin(&txp->tsync);
txp->tx_packets++;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index b53c0cfd417e..570f60ec6cb4 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -589,6 +589,7 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1,
* @pkt_type: Packet class
* @fclone: skbuff clone status
* @ipvs_property: skbuff is owned by ipvs
+ * @tc_skip_classify: do not classify packet. set by IFB device
* @peeked: this packet has been seen already, so stats have been
* done for it, don't do them again
* @nf_trace: netfilter packet trace flag
@@ -749,7 +750,9 @@ struct sk_buff {
#ifdef CONFIG_NET_SWITCHDEV
__u8 offload_fwd_mark:1;
#endif
- /* 2, 4 or 5 bit hole */
+#ifdef CONFIG_NET_CLS_ACT
+ __u8 tc_skip_classify:1;
+#endif
#ifdef CONFIG_NET_SCHED
__u16 tc_index; /* traffic control index */
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 498f81b229a4..857356f2d74b 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -418,6 +418,17 @@ static inline bool skb_at_tc_ingress(const struct sk_buff *skb)
#endif
}
+static inline bool skb_skip_tc_classify(struct sk_buff *skb)
+{
+#ifdef CONFIG_NET_CLS_ACT
+ if (skb->tc_skip_classify) {
+ skb->tc_skip_classify = 0;
+ return true;
+ }
+#endif
+ return false;
+}
+
/* Reset all TX qdiscs greater then index of a device. */
static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i)
{
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index bba23dbb3ab6..1eed5d7509bc 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -22,8 +22,6 @@ bit 6,7: Where this packet was last seen
1: on the Ingress
2: on the Egress
-bit 8: when set --> Request not to classify on ingress.
-
*
* */
@@ -36,10 +34,6 @@ bit 8: when set --> Request not to classify on ingress.
#define AT_INGRESS 0x1
#define AT_EGRESS 0x2
-#define TC_NCLS _TC_MAKEMASK1(8)
-#define SET_TC_NCLS(v) ( TC_NCLS | (v & ~TC_NCLS))
-#define CLR_TC_NCLS(v) ( v & ~TC_NCLS)
-
#define S_TC_AT _TC_MAKE32(12)
#define M_TC_AT _TC_MAKEMASK(2,S_TC_AT)
#define G_TC_AT(x) _TC_GETVALUE(x,S_TC_AT,M_TC_AT)
diff --git a/net/core/dev.c b/net/core/dev.c
index 56818f7eab2b..e39e35d2e082 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4093,12 +4093,8 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
goto out;
}
-#ifdef CONFIG_NET_CLS_ACT
- if (skb->tc_verd & TC_NCLS) {
- skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
- goto ncls;
- }
-#endif
+ if (skb_skip_tc_classify(skb))
+ goto skip_classify;
if (pfmemalloc)
goto skip_taps;
@@ -4128,8 +4124,8 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
#endif
#ifdef CONFIG_NET_CLS_ACT
skb->tc_verd = 0;
-ncls:
#endif
+skip_classify:
if (pfmemalloc && !skb_pfmemalloc_protocol(skb))
goto drop;
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 2095c83ce773..f04715a57300 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -426,11 +426,9 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
{
int ret = -1, i;
- if (skb->tc_verd & TC_NCLS) {
- skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
- ret = TC_ACT_OK;
- goto exec_done;
- }
+ if (skb_skip_tc_classify(skb))
+ return TC_ACT_OK;
+
for (i = 0; i < nr_actions; i++) {
const struct tc_action *a = actions[i];
@@ -439,9 +437,8 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
if (ret == TC_ACT_REPEAT)
goto repeat; /* we need a ttl - JHS */
if (ret != TC_ACT_PIPE)
- goto exec_done;
+ break;
}
-exec_done:
return ret;
}
EXPORT_SYMBOL(tcf_action_exec);
--
2.11.0.390.gc69c2f50cf-goog
^ permalink raw reply related
* [PATCH net-next 2/6] net-tc: make MAX_RECLASSIFY_LOOP local
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
To: netdev
Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
Willem de Bruijn
In-Reply-To: <20170107220638.61314-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
This field is no longer kept in tc_verd. Remove it from the global
definition of that struct.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
include/uapi/linux/pkt_cls.h | 5 -----
net/sched/sch_api.c | 3 ++-
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index c769f71972f5..bba23dbb3ab6 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -17,9 +17,6 @@
/* verdict bit breakdown
*
-bit 2,3,4,5: Reclassify counter - sort of reverse TTL - if exceeded
-assume loop
-
bit 6,7: Where this packet was last seen
0: Above the transmit example at the socket level
1: on the Ingress
@@ -48,8 +45,6 @@ bit 8: when set --> Request not to classify on ingress.
#define G_TC_AT(x) _TC_GETVALUE(x,S_TC_AT,M_TC_AT)
#define V_TC_AT(x) _TC_MAKEVALUE(x,S_TC_AT)
#define SET_TC_AT(v,n) ((V_TC_AT(n)) | (v & ~M_TC_AT))
-
-#define MAX_REC_LOOP 4
#endif
/* Action attributes */
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index d7b93429f0cc..ef53ede11590 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1861,6 +1861,7 @@ int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp,
{
__be16 protocol = tc_skb_protocol(skb);
#ifdef CONFIG_NET_CLS_ACT
+ const int max_reclassify_loop = 4;
const struct tcf_proto *old_tp = tp;
int limit = 0;
@@ -1885,7 +1886,7 @@ int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp,
return TC_ACT_UNSPEC; /* signal: continue lookup */
#ifdef CONFIG_NET_CLS_ACT
reset:
- if (unlikely(limit++ >= MAX_REC_LOOP)) {
+ if (unlikely(limit++ >= max_reclassify_loop)) {
net_notice_ratelimited("%s: reclassify loop, rule prio %u, protocol %02x\n",
tp->q->ops->id, tp->prio & 0xffff,
ntohs(tp->protocol));
--
2.11.0.390.gc69c2f50cf-goog
^ permalink raw reply related
* [PATCH net-next 1/6] net-tc: remove unused tc_verd fields
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
To: netdev
Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
Willem de Bruijn
In-Reply-To: <20170107220638.61314-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
Remove the last reference to tc_verd's munge and redirect ttl bits.
These fields are no longer used.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
include/uapi/linux/pkt_cls.h | 7 -------
1 file changed, 7 deletions(-)
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index cb4bcdc58543..c769f71972f5 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -17,10 +17,6 @@
/* verdict bit breakdown
*
-bit 0: when set -> this packet has been munged already
-
-bit 1: when set -> It is ok to munge this packet
-
bit 2,3,4,5: Reclassify counter - sort of reverse TTL - if exceeded
assume loop
@@ -31,8 +27,6 @@ bit 6,7: Where this packet was last seen
bit 8: when set --> Request not to classify on ingress.
-bits 9,10,11: redirect counter - redirect TTL. Loop avoidance
-
*
* */
@@ -56,7 +50,6 @@ bits 9,10,11: redirect counter - redirect TTL. Loop avoidance
#define SET_TC_AT(v,n) ((V_TC_AT(n)) | (v & ~M_TC_AT))
#define MAX_REC_LOOP 4
-#define MAX_RED_LOOP 4
#endif
/* Action attributes */
--
2.11.0.390.gc69c2f50cf-goog
^ permalink raw reply related
* [PATCH net-next 0/6] convert tc_verd to integer bitfields
From: Willem de Bruijn @ 2017-01-07 22:06 UTC (permalink / raw)
To: netdev
Cc: davem, fw, dborkman, jhs, alexei.starovoitov, eric.dumazet,
Willem de Bruijn
From: Willem de Bruijn <willemb@google.com>
The skb tc_verd field takes up two bytes but uses far fewer bits.
Convert the remaining use cases to bitfields that fit in existing
holes (depending on config options) and potentially save the two
bytes in struct sk_buff.
This patchset is based on an earlier set by Florian Westphal and its
discussion (http://www.spinics.net/lists/netdev/msg329181.html).
Patches 1 and 2 are low hanging fruit: removing the last traces of
data that are no longer stored in tc_verd.
Patches 3 and 4 convert tc_verd to individual bitfields (5 bits).
Patch 5 reduces TC_AT to a single bitfield,
as AT_STACK is not valid here (unlike in the case of TC_FROM).
Patch 6 changes TC_FROM to two bitfields with clearly defined purpose.
It may be possible to reduce storage further after this initial round.
If tc_skip_classify is set only by IFB, testing skb_iif may suffice.
The L2 header pushing/popping logic can perhaps be shared with
AF_PACKET, which currently not pkt_type for the same purpose.
Changes:
RFC -> v1
- (patch 3): remove no longer needed label in tfc_action_exec
- (patch 5): set tc_at_ingress at the same points as existing
SET_TC_AT calls
Tested ingress mirred + netem + ifb:
ip link set dev ifb0 up
tc qdisc add dev eth0 ingress
tc filter add dev eth0 parent ffff: \
u32 match ip dport 8000 0xffff \
action mirred egress redirect dev ifb0
tc qdisc add dev ifb0 root netem delay 1000ms
nc -u -l 8000 &
ssh $otherhost nc -u $host 8000
Tested egress mirred:
ip link add veth1 type veth peer name veth2
ip link set dev veth1 up
ip link set dev veth2 up
tcpdump -n -i veth2 udp and dst port 8000 &
tc qdisc add dev eth0 root handle 1: prio
tc filter add dev eth0 parent 1:0 \
u32 match ip dport 8000 0xffff \
action mirred egress redirect dev veth1
tc qdisc add dev veth1 root netem delay 1000ms
nc -u $otherhost 8000
Tested ingress mirred:
ip link add veth1 type veth peer name veth2
ip link add veth3 type veth peer name veth4
ip netns add ns0
ip netns add ns1
for i in 1 2 3 4; do \
NS=ns$((${i}%2)); \
ip link set dev veth${i} netns ${NS}; \
ip netns exec ${NS} \
ip addr add dev veth${i} 192.168.1.${i}/24; \
ip netns exec ${NS} \
ip link set dev veth${i} up; \
done
ip netns exec ns0 tc qdisc add dev veth2 ingress
ip netns exec ns0 \
tc filter add dev veth2 parent ffff: \
u32 match ip dport 8000 0xffff \
action mirred ingress redirect dev veth4
ip netns exec ns0 \
tcpdump -n -i veth4 udp and dst port 8000 &
ip netns exec ns1 \
nc -u 192.168.1.2 8000
Willem de Bruijn (6):
net-tc: remove unused tc_verd fields
net-tc: make MAX_RECLASSIFY_LOOP local
net-tc: extract skip classify bit from tc_verd
net-tc: convert tc_verd to integer bitfields
net-tc: convert tc_at to tc_at_ingress
net-tc: convert tc_from to tc_from_ingress and tc_redirected
drivers/net/ifb.c | 16 ++++-------
drivers/staging/octeon/ethernet-tx.c | 5 ++--
include/linux/skbuff.h | 15 ++++++----
include/net/sch_generic.h | 20 ++++++++++++-
include/uapi/linux/pkt_cls.h | 55 ------------------------------------
net/core/dev.c | 22 +++++----------
net/core/pktgen.c | 4 +--
net/core/skbuff.c | 3 --
net/sched/act_api.c | 11 +++-----
net/sched/act_ife.c | 7 ++---
net/sched/act_mirred.c | 21 +++++++-------
net/sched/sch_api.c | 3 +-
net/sched/sch_netem.c | 2 +-
13 files changed, 66 insertions(+), 118 deletions(-)
--
2.11.0.390.gc69c2f50cf-goog
^ permalink raw reply
* Re: [PATCH v2 net-next 3/4] secure_seq: use SipHash in place of MD5
From: David Miller @ 2017-01-07 21:37 UTC (permalink / raw)
To: Jason
Cc: ebiggers3, jeanphilippe.aumasson, gregkh, netdev, linux-kernel,
ak, David.Laight, tom, hannes, eric.dumazet
In-Reply-To: <20170107144057.15432-4-Jason@zx2c4.com>
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Sat, 7 Jan 2017 15:40:56 +0100
> This gives a clear speed and security improvement. Siphash is both
> faster and is more solid crypto than the aging MD5.
>
> Rather than manually filling MD5 buffers, for IPv6, we simply create
> a layout by a simple anonymous struct, for which gcc generates
> rather efficient code. For IPv4, we pass the values directly to the
> short input convenience functions.
>
> 64-bit x86_64:
> [ 1.683628] secure_tcpv6_sequence_number_md5# cycles: 99563527
> [ 1.717350] secure_tcp_sequence_number_md5# cycles: 92890502
> [ 1.741968] secure_tcpv6_sequence_number_siphash# cycles: 67825362
> [ 1.762048] secure_tcp_sequence_number_siphash# cycles: 67485526
>
> 32-bit x86:
> [ 1.600012] secure_tcpv6_sequence_number_md5# cycles: 103227892
> [ 1.634219] secure_tcp_sequence_number_md5# cycles: 94732544
> [ 1.669102] secure_tcpv6_sequence_number_siphash# cycles: 96299384
> [ 1.700165] secure_tcp_sequence_number_siphash# cycles: 86015473
>
> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This and the next patch are a real shame, performance wise, on cpus
that have single-instruction SHA1 and MD5 implementations. Sparc64
has both, and I believe x86_64 can do SHA1 these days.
It took so long to get those instructions into real silicon, and then
have software implemented to make use of them as well.
Who knows when we'll see SipHash widely deployed in any instruction
set, if at all, right? And by that time we'll possibly find out that
"Oh shit, this SipHash thing has flaws!" and we'll need
DIPPY_DO_DA_HASH and thus be forced back to a software implementation
again.
I understand the reasons why these patches are being proposed, I just
thought I'd mention the issue of cpus that implement secure hash
algorithm instructions.
^ permalink raw reply
* [PATCH] net: ibm: ibmvnic: use new api ethtool_{get|set}_link_ksettings
From: Philippe Reynes @ 2017-01-07 21:37 UTC (permalink / raw)
To: tlfalcon, jallen, benh, paulus, mpe, davem
Cc: netdev, linuxppc-dev, linux-kernel, Philippe Reynes
The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.
Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
drivers/net/ethernet/ibm/ibmvnic.c | 31 ++++++++++++++++++-------------
1 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index c125966..3c2526b 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1025,21 +1025,26 @@ static void ibmvnic_netpoll_controller(struct net_device *dev)
/* ethtool functions */
-static int ibmvnic_get_settings(struct net_device *netdev,
- struct ethtool_cmd *cmd)
+static int ibmvnic_get_link_ksettings(struct net_device *netdev,
+ struct ethtool_link_ksettings *cmd)
{
- cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg |
+ u32 supported, advertising;
+
+ supported = (SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg |
SUPPORTED_FIBRE);
- cmd->advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg |
+ advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg |
ADVERTISED_FIBRE);
- ethtool_cmd_speed_set(cmd, SPEED_1000);
- cmd->duplex = DUPLEX_FULL;
- cmd->port = PORT_FIBRE;
- cmd->phy_address = 0;
- cmd->transceiver = XCVR_INTERNAL;
- cmd->autoneg = AUTONEG_ENABLE;
- cmd->maxtxpkt = 0;
- cmd->maxrxpkt = 1;
+ cmd->base.speed = SPEED_1000;
+ cmd->base.duplex = DUPLEX_FULL;
+ cmd->base.port = PORT_FIBRE;
+ cmd->base.phy_address = 0;
+ cmd->base.autoneg = AUTONEG_ENABLE;
+
+ ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
+ supported);
+ ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
+ advertising);
+
return 0;
}
@@ -1132,7 +1137,6 @@ static void ibmvnic_get_ethtool_stats(struct net_device *dev,
}
static const struct ethtool_ops ibmvnic_ethtool_ops = {
- .get_settings = ibmvnic_get_settings,
.get_drvinfo = ibmvnic_get_drvinfo,
.get_msglevel = ibmvnic_get_msglevel,
.set_msglevel = ibmvnic_set_msglevel,
@@ -1141,6 +1145,7 @@ static void ibmvnic_get_ethtool_stats(struct net_device *dev,
.get_strings = ibmvnic_get_strings,
.get_sset_count = ibmvnic_get_sset_count,
.get_ethtool_stats = ibmvnic_get_ethtool_stats,
+ .get_link_ksettings = ibmvnic_get_link_ksettings,
};
/* Routines for managing CRQs/sCRQs */
--
1.7.4.4
^ permalink raw reply related
* [PATCH] net: ibm: ibmveth: use new api ethtool_{get|set}_link_ksettings
From: Philippe Reynes @ 2017-01-07 21:35 UTC (permalink / raw)
To: benh, paulus, mpe, tlfalcon, davem
Cc: linuxppc-dev, netdev, linux-kernel, Philippe Reynes
The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.
Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 30 ++++++++++++++++++------------
1 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index a831f94..c6ba75c 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -729,20 +729,26 @@ static int ibmveth_close(struct net_device *netdev)
return 0;
}
-static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+static int netdev_get_link_ksettings(struct net_device *dev,
+ struct ethtool_link_ksettings *cmd)
{
- cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg |
+ u32 supported, advertising;
+
+ supported = (SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg |
SUPPORTED_FIBRE);
- cmd->advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg |
+ advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg |
ADVERTISED_FIBRE);
- ethtool_cmd_speed_set(cmd, SPEED_1000);
- cmd->duplex = DUPLEX_FULL;
- cmd->port = PORT_FIBRE;
- cmd->phy_address = 0;
- cmd->transceiver = XCVR_INTERNAL;
- cmd->autoneg = AUTONEG_ENABLE;
- cmd->maxtxpkt = 0;
- cmd->maxrxpkt = 1;
+ cmd->base.speed = SPEED_1000;
+ cmd->base.duplex = DUPLEX_FULL;
+ cmd->base.port = PORT_FIBRE;
+ cmd->base.phy_address = 0;
+ cmd->base.autoneg = AUTONEG_ENABLE;
+
+ ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
+ supported);
+ ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
+ advertising);
+
return 0;
}
@@ -978,11 +984,11 @@ static void ibmveth_get_ethtool_stats(struct net_device *dev,
static const struct ethtool_ops netdev_ethtool_ops = {
.get_drvinfo = netdev_get_drvinfo,
- .get_settings = netdev_get_settings,
.get_link = ethtool_op_get_link,
.get_strings = ibmveth_get_strings,
.get_sset_count = ibmveth_get_sset_count,
.get_ethtool_stats = ibmveth_get_ethtool_stats,
+ .get_link_ksettings = netdev_get_link_ksettings,
};
static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
--
1.7.4.4
^ permalink raw reply related
* [PATCH] net: ibm: emac: use new api ethtool_{get|set}_link_ksettings
From: Philippe Reynes @ 2017-01-07 21:32 UTC (permalink / raw)
To: davem, ivan, jarod, mugunthanvnm, felipe.balbi, fw, mpe
Cc: netdev, linux-kernel, Philippe Reynes
The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.
Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
drivers/net/ethernet/ibm/emac/core.c | 70 +++++++++++++++++++--------------
1 files changed, 40 insertions(+), 30 deletions(-)
diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index 5909615..6ead233 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -1991,69 +1991,79 @@ static irqreturn_t emac_irq(int irq, void *dev_instance)
};
/* Ethtool support */
-static int emac_ethtool_get_settings(struct net_device *ndev,
- struct ethtool_cmd *cmd)
+static int emac_ethtool_get_link_ksettings(struct net_device *ndev,
+ struct ethtool_link_ksettings *cmd)
{
struct emac_instance *dev = netdev_priv(ndev);
+ u32 supported, advertising;
- cmd->supported = dev->phy.features;
- cmd->port = PORT_MII;
- cmd->phy_address = dev->phy.address;
- cmd->transceiver =
- dev->phy.address >= 0 ? XCVR_EXTERNAL : XCVR_INTERNAL;
+ supported = dev->phy.features;
+ cmd->base.port = PORT_MII;
+ cmd->base.phy_address = dev->phy.address;
mutex_lock(&dev->link_lock);
- cmd->advertising = dev->phy.advertising;
- cmd->autoneg = dev->phy.autoneg;
- cmd->speed = dev->phy.speed;
- cmd->duplex = dev->phy.duplex;
+ advertising = dev->phy.advertising;
+ cmd->base.autoneg = dev->phy.autoneg;
+ cmd->base.speed = dev->phy.speed;
+ cmd->base.duplex = dev->phy.duplex;
mutex_unlock(&dev->link_lock);
+ ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
+ supported);
+ ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
+ advertising);
+
return 0;
}
-static int emac_ethtool_set_settings(struct net_device *ndev,
- struct ethtool_cmd *cmd)
+static int
+emac_ethtool_set_link_ksettings(struct net_device *ndev,
+ const struct ethtool_link_ksettings *cmd)
{
struct emac_instance *dev = netdev_priv(ndev);
u32 f = dev->phy.features;
+ u32 advertising;
+
+ ethtool_convert_link_mode_to_legacy_u32(&advertising,
+ cmd->link_modes.advertising);
DBG(dev, "set_settings(%d, %d, %d, 0x%08x)" NL,
- cmd->autoneg, cmd->speed, cmd->duplex, cmd->advertising);
+ cmd->base.autoneg, cmd->base.speed, cmd->base.duplex, advertising);
/* Basic sanity checks */
if (dev->phy.address < 0)
return -EOPNOTSUPP;
- if (cmd->autoneg != AUTONEG_ENABLE && cmd->autoneg != AUTONEG_DISABLE)
+ if (cmd->base.autoneg != AUTONEG_ENABLE &&
+ cmd->base.autoneg != AUTONEG_DISABLE)
return -EINVAL;
- if (cmd->autoneg == AUTONEG_ENABLE && cmd->advertising == 0)
+ if (cmd->base.autoneg == AUTONEG_ENABLE && advertising == 0)
return -EINVAL;
- if (cmd->duplex != DUPLEX_HALF && cmd->duplex != DUPLEX_FULL)
+ if (cmd->base.duplex != DUPLEX_HALF && cmd->base.duplex != DUPLEX_FULL)
return -EINVAL;
- if (cmd->autoneg == AUTONEG_DISABLE) {
- switch (cmd->speed) {
+ if (cmd->base.autoneg == AUTONEG_DISABLE) {
+ switch (cmd->base.speed) {
case SPEED_10:
- if (cmd->duplex == DUPLEX_HALF &&
+ if (cmd->base.duplex == DUPLEX_HALF &&
!(f & SUPPORTED_10baseT_Half))
return -EINVAL;
- if (cmd->duplex == DUPLEX_FULL &&
+ if (cmd->base.duplex == DUPLEX_FULL &&
!(f & SUPPORTED_10baseT_Full))
return -EINVAL;
break;
case SPEED_100:
- if (cmd->duplex == DUPLEX_HALF &&
+ if (cmd->base.duplex == DUPLEX_HALF &&
!(f & SUPPORTED_100baseT_Half))
return -EINVAL;
- if (cmd->duplex == DUPLEX_FULL &&
+ if (cmd->base.duplex == DUPLEX_FULL &&
!(f & SUPPORTED_100baseT_Full))
return -EINVAL;
break;
case SPEED_1000:
- if (cmd->duplex == DUPLEX_HALF &&
+ if (cmd->base.duplex == DUPLEX_HALF &&
!(f & SUPPORTED_1000baseT_Half))
return -EINVAL;
- if (cmd->duplex == DUPLEX_FULL &&
+ if (cmd->base.duplex == DUPLEX_FULL &&
!(f & SUPPORTED_1000baseT_Full))
return -EINVAL;
break;
@@ -2062,8 +2072,8 @@ static int emac_ethtool_set_settings(struct net_device *ndev,
}
mutex_lock(&dev->link_lock);
- dev->phy.def->ops->setup_forced(&dev->phy, cmd->speed,
- cmd->duplex);
+ dev->phy.def->ops->setup_forced(&dev->phy, cmd->base.speed,
+ cmd->base.duplex);
mutex_unlock(&dev->link_lock);
} else {
@@ -2072,7 +2082,7 @@ static int emac_ethtool_set_settings(struct net_device *ndev,
mutex_lock(&dev->link_lock);
dev->phy.def->ops->setup_aneg(&dev->phy,
- (cmd->advertising & f) |
+ (advertising & f) |
(dev->phy.advertising &
(ADVERTISED_Pause |
ADVERTISED_Asym_Pause)));
@@ -2234,8 +2244,6 @@ static void emac_ethtool_get_drvinfo(struct net_device *ndev,
}
static const struct ethtool_ops emac_ethtool_ops = {
- .get_settings = emac_ethtool_get_settings,
- .set_settings = emac_ethtool_set_settings,
.get_drvinfo = emac_ethtool_get_drvinfo,
.get_regs_len = emac_ethtool_get_regs_len,
@@ -2251,6 +2259,8 @@ static void emac_ethtool_get_drvinfo(struct net_device *ndev,
.get_ethtool_stats = emac_ethtool_get_ethtool_stats,
.get_link = ethtool_op_get_link,
+ .get_link_ksettings = emac_ethtool_get_link_ksettings,
+ .set_link_ksettings = emac_ethtool_set_link_ksettings,
};
static int emac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
--
1.7.4.4
^ permalink raw reply related
* Re: [PATCH net-next 1/2] net: dsa: make "label" property optional for dsa2
From: Uwe Kleine-König @ 2017-01-07 20:31 UTC (permalink / raw)
To: Vivien Didelot, netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn
In-Reply-To: <20170106220043.21280-2-vivien.didelot@savoirfairelinux.com>
[-- Attachment #1.1: Type: text/plain, Size: 1087 bytes --]
Hello,
On 01/06/2017 11:00 PM, Vivien Didelot wrote:
> In the new DTS bindings for DSA (dsa2), the "ethernet" and "link"
> phandles are respectively mandatory and exclusive to CPU port and DSA
> link device tree nodes.
>
> Simplify dsa2.c a bit by checking the presence of such phandle instead
> of checking the redundant "label" property.
>
> Then the Linux philosophy for Ethernet switch ports is to expose them to
> userspace as standard NICs by default. Thus use the standard enumerated
> "eth%d" device name if no "label" property is provided for a user port.
> This allows to save DTS files from subjective net device names.
>
> If one wants to rename an interface, udev rules can be used as usual.
> The sysfs phys_port_id and phys_switch_id also provide physical data.
>
> Of course the current behavior is unchanged, and the optional "label"
> property for user ports has precedence over the enumerated name.
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Acked-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Thanks
Uwe
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [PATCH net-next 1/2] net: dsa: make "label" property optional for dsa2
From: Uwe Kleine-König @ 2017-01-07 20:28 UTC (permalink / raw)
To: Florian Fainelli, Andrew Lunn, Vivien Didelot
Cc: netdev, linux-kernel, kernel, David S. Miller
In-Reply-To: <0dbf9730-2409-30f9-e9e4-946fe7fec413@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1049 bytes --]
Hello,
On 01/06/2017 11:47 PM, Florian Fainelli wrote:
> On 01/06/2017 02:20 PM, Andrew Lunn wrote:
>>> If one wants to rename an interface, udev rules can be used as usual.
>>
>> Hi Vivien
>>
>> Do you have some examples?
>>
>> A quick look at udevadm info suggests we can use
>>
>> ATTR{phys_port_id} and ATTR{phys_switch_id}
>>
>> Humm, it would be nice to know why the second switch has a
>> phys_switch_id of 01000000.
>
> Well, that's a combination of being on a little endian system and using
> %*phN as a printk formatter, and the type being 32-bit long (int). I
> agree this does not feel natural, but since this is sysfs (so ABI in a
> way), it's going to be though to change now.
for most subsystems I know the internally used (and more or less
automatically determined) numbers are not to be considered stable.
For example the GPIO made it possible to let userspace work with GPIOs
without knowing (or having to determine) the gpio numbers.
I don't know if/how this applies here.
Best regards
Uwe
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: More info about lockless qdisc patch
From: John Fastabend @ 2017-01-07 20:11 UTC (permalink / raw)
To: Xingjun Liu, john.r.fastabend; +Cc: netdev
In-Reply-To: <D1B824B6-91C1-4049-8231-048FD900D160@gmail.com>
On 16-12-30 04:48 AM, Xingjun Liu wrote:
> Hi John,
>
> I note you have a patch request last august about "support lockless qdisc”,
>
> see: https://www.mail-archive.com/netdev@vger.kernel.org/msg124489.html
I have another set of patches that fixes a few bugs from the above.
>
> We take an interest in it. Do you have any info/plan on this patch?
>
The current state of the patches (the latest I have on my private tree) is
currently
I an issue with re-starting the driver when multiple cores do a dequeue but the
driver overruns the hardware descriptor ring so we push back into the qdisc. When
this happens the patches push the skb onto the gso_skb per cpu list.
Now the problem is how do we wake the correct gso_skb per cpu list up? The driver
will restart the qdisc at some future point but not necessarily from the same
cpu that
the per cpu enqueue happened on. So I tried to fix this by removing the driver
restart
logic and having the qdisc layer poll the driver. This sort of/kind of works
except its not
a very satisfying solution. Tom noted at one point with BQL the above case
should not
happen very much but it is still possible unfortunately under certain
conditions. And the
corner cases get ugly.
I've been kicking around another idea lately. To get rid of the gso_skb entirely
which
would certainly clean up the code and get rid of one of the uglier pieces of
qdisc struct
in my opinion. To make this work I want to add a tx_prep() ndo call the qdisc
could call
into the driver with to reserve "slots" in the driver. Once we have some # of
slots reserved
we can dequeue from the qdisc ring and send to driver "knowing" that the driver has
agreed to consume the packets. The trick here is sk_buffs do not map 1:1 with
descriptors
in the hardware always so a bit of driver magic needs to occur to get
calculations correct.
I'll try to rebase the current set of patches I have on net-next and post it
just so its
available. I can probably get to the above in a month or so. Maybe have something by
March.
Thanks,
John
> Thanks
> Xingjun
>
^ permalink raw reply
* Re: [PATCHv2 net-next 11/16] net: mvpp2: handle misc PPv2.1/PPv2.2 differences
From: Russell King - ARM Linux @ 2017-01-07 20:10 UTC (permalink / raw)
To: Thomas Petazzoni
Cc: Mark Rutland, devicetree-u79uwXL29TY76Z2rM5mHXA, Yehuda Yitschak,
Jason Cooper, Pawel Moll, Ian Campbell,
netdev-u79uwXL29TY76Z2rM5mHXA, Hanna Hawa, Nadav Haklai,
Rob Herring, Andrew Lunn, Kumar Gala, Gregory Clement,
Stefan Chulski, Marcin Wojtas, David S. Miller,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
Sebastian Hesselbarth
In-Reply-To: <20170107093834.GJ14217-l+eeeJia6m9URfEZ8mYm6t73F7V6hmMc@public.gmane.org>
On Sat, Jan 07, 2017 at 09:38:34AM +0000, Russell King - ARM Linux wrote:
> On Wed, Dec 28, 2016 at 05:46:27PM +0100, Thomas Petazzoni wrote:
> > @@ -6511,7 +6515,9 @@ static int mvpp2_port_probe(struct platform_device *pdev,
> > dev_err(&pdev->dev, "failed to init port %d\n", id);
> > goto err_free_stats;
> > }
> > - mvpp2_port_power_up(port);
> > +
> > + if (priv->hw_version == MVPP21)
> > + mvpp21_port_power_up(port);
>
> This has the side effect that nothing clears the port reset bit in the
> GMAC, which means there's no hope of the interface working - with the
> reset bit set, the port is well and truely held in "link down" state.
>
> In any case, the GMAC part is much the same as mvneta, and I think
> that code should be shared rather than writing new versions of it.
> There are some subtle differences between neta, pp2.1 and pp2.2, but
> it's entirely doable (I have an implementation here as I wasn't going
> to duplicate this code for my phylink conversion.)
In addition to comphy configuration and the above, I also need the
following to have working SGMII. The change of MACMODE is needed
because uboot has configured the port for 10Gbase-R mode (it has a
10G PHY on it, but the PHY switches to SGMII in <10G modes.) The
GMAC control register 4 is needed to properly configure for SGMII
mode. I also included RGMII mode as well in there, as I expect you'd
need it to have GMAC properly configured for RGMII.
With this in place (and the other bits mentioned above), I can ping
the clearfog switch on the other end of eth0's cable:
# ping6 -I eth0 fe80::250:43ff:fe02:302
PING fe80::250:43ff:fe02:302(fe80::250:43ff:fe02:302) from fe80::200:ff:fe00:1 eth0: 56 data bytes
64 bytes from fe80::250:43ff:fe02:302: icmp_seq=1 ttl=64 time=0.297 ms
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index bc97eebf7eee..4b6ec6213e9c 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -345,7 +345,17 @@
#define MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK 0x1fc0
#define MVPP2_GMAC_TX_FIFO_MIN_TH_MASK(v) (((v) << 6) & \
MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK)
+#define MVPP22_GMAC_CTRL_4_REG 0x90
+#define MVPP22_CTRL4_EXT_PIN_GMII_SEL BIT(0)
+#define MVPP22_CTRL4_DP_CLK_SEL BIT(5)
+#define MVPP22_CTRL4_SYNC_BYPASS BIT(6)
+#define MVPP22_CTRL4_QSGMII_BYPASS_ACTIVE BIT(7)
+
+#define MVPP22_XLG_CTRL3_REG 0x11c
+#define MVPP22_XLG_CTRL3_MACMODESELECT_MASK (7 << 13)
+#define MVPP22_XLG_CTRL3_MACMODESELECT_GMAC (0 << 13)
+/* offsets from iface_base */
#define MVPP22_SMI_MISC_CFG_REG 0x2a204
#define MVPP22_SMI_POLLING_EN BIT(10)
@@ -4171,6 +4181,23 @@ static void mvpp2_port_mii_set(struct mvpp2_port *port)
{
u32 val;
+ if (port->priv->hw_version == MVPP22) {
+ val = readl(port->base + MVPP22_XLG_CTRL3_REG);
+ val &= ~MVPP22_XLG_CTRL3_MACMODESELECT_MASK;
+ val |= MVPP22_XLG_CTRL3_MACMODESELECT_GMAC;
+ writel(val, port->base + MVPP22_XLG_CTRL3_REG);
+
+ val = readl(port->base + MVPP22_GMAC_CTRL_4_REG);
+ if (port->phy_interface == PHY_INTERFACE_MODE_RGMII)
+ val |= MVPP22_CTRL4_EXT_PIN_GMII_SEL;
+ else
+ val &= ~MVPP22_CTRL4_EXT_PIN_GMII_SEL;
+ val &= ~MVPP22_CTRL4_DP_CLK_SEL;
+ val |= MVPP22_CTRL4_SYNC_BYPASS;
+ val |= MVPP22_CTRL4_QSGMII_BYPASS_ACTIVE;
+ writel(val, port->base + MVPP22_GMAC_CTRL_4_REG);
+ }
+
val = readl(port->base + MVPP2_GMAC_CTRL_2_REG);
switch (port->phy_interface) {
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* Re: [PATCH v2 net-next 0/4] Introduce The SipHash PRF
From: Eric Biggers @ 2017-01-07 19:54 UTC (permalink / raw)
To: Jason A. Donenfeld
Cc: davem, jeanphilippe.aumasson, gregkh, netdev, linux-kernel
In-Reply-To: <20170107144057.15432-1-Jason@zx2c4.com>
On Sat, Jan 07, 2017 at 03:40:53PM +0100, Jason A. Donenfeld wrote:
> This patch series introduces SipHash into the kernel. SipHash is a
> cryptographically secure PRF, which serves a variety of functions, and is
> introduced in patch #1. The following patch #2 introduces HalfSipHash,
> an optimization suitable for hash tables only. Finally, the last two patches
> in this series show two usages of the introduced siphash function family.
> It is expected that after this initial introductin, other usages will follow.
...
> The use of SipHash is not limited to the networking subsystem -- indeed I
> would like to use it in other places too in the kernel. But after discussing
> with a few on this list and at Linus' suggestion, the initial import of these
> functions is coming through the networking tree. After these are merged, it
> will then be easier to expand use elsewhere.
>
> Changes v1->v2:
> - len in the macro is now (len).
> - siphash_key_t is now a struct, so that passing by reference is more
> obvious and clear. This required changing all the call sites.
> - Rather than calling le32_to_cpu(data[0]), where data is a u64, we now
> do the safer thing and call le32_to_cpup((const __le32 *)data).
> - The alignment in the tests is now more explicit.
> - Sparse no longer complains, after fixing up a few endian casts.
> - White space fixups.
> - Word wrapping fixes.
> - The valid suggestions from checkpatch.
Hi Jason, thanks for doing this! Yes, I had gotten a little lost in the earlier
discussions about the 'random' driver and other potential users of SipHash. I
agree with the approach to just introduce the two uses in net/ to start with,
and introduce more users later. The changes from v1 to v2 look good too.
Now that the HalfSipHash patch is Cc'ed to me too I do have one other small
suggestion which is that this:
#if BITS_PER_LONG == 64
typedef siphash_key_t hsiphash_key_t;
#define HSIPHASH_ALIGNMENT SIPHASH_ALIGNMENT
#else
typedef struct {
u32 key[2];
} hsiphash_key_t;
#define HSIPHASH_ALIGNMENT __alignof__(u32)
#endif
could cause confusion if someone accidentally uses 'siphash_key_t' instead of
'hsiphash_key_t', as their code would compile fine on a 64-bit platform but
would fail to compile on a 32-bit platform. I think there should just always be
a hsiphash_key_t struct defined, and it can use unsigned long (no need for an
#ifdef):
#define HSIPHASH_ALIGNMENT __alignof__(unsigned long)
typedef struct {
unsigned long key[2];
} hsiphash_key_t;
There's also a small error in Documentation/siphash.txt: hsiphash() is shown as
taking siphash_key_t instead of hsiphash_key_t.
The uses in net look good too. Something to watch out for is accidentally
defining the structs in a way that leaves internal padding bytes, which could
theoretically take on any value and cause the same input to produce different
hashes. But AFAICS, in the proposed patch all the structs are laid out
properly, so that won't happen.
'net_secret' could also be marked as __read_mostly, like the keys in
syncookies.c, I suppose; it may not matter much.
Thanks!
Eric
^ permalink raw reply
* [RFC PATCH] intel: Use upper_32_bits and lower_32_bits
From: Joe Perches @ 2017-01-07 18:32 UTC (permalink / raw)
To: Jeff Kirsher; +Cc: Julia Lawall, intel-wired-lan, netdev, linux-kernel
Shifting and masking various types can be made a bit
simpler to read by using the available kernel macros.
Signed-off-by: Joe Perches <joe@perches.com>
---
This RFC patch is meant as an example, not necessarily
to apply, though it does compile to equivalent code.
It does seem a bit simpler for a human to read.
Perhaps this could be automated via a coccinelle script,
but this was done with grep & sed and some typing.
Treewide, there are many hundred instances of this style code
that could be converted.
Dunno if it's really worth it though.
Another usage that could be converted is DMA_BIT_MASK(32)
where it is equivalent to upper_32_bits and lower_32_bits.
drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 8 ++++----
drivers/net/ethernet/intel/e1000/e1000_main.c | 8 ++++----
drivers/net/ethernet/intel/e1000e/ethtool.c | 8 ++++----
drivers/net/ethernet/intel/fm10k/fm10k_common.c | 4 ++--
drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 2 +-
drivers/net/ethernet/intel/i40e/i40e_common.c | 4 ++--
drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 8 ++++----
drivers/net/ethernet/intel/i40e/i40e_main.c | 4 ++--
drivers/net/ethernet/intel/i40e/i40e_ptp.c | 12 ++++++------
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 9 +++++----
drivers/net/ethernet/intel/i40evf/i40evf_main.c | 4 ++--
drivers/net/ethernet/intel/igb/igb_main.c | 10 ++++------
drivers/net/ethernet/intel/igb/igb_ptp.c | 4 ++--
drivers/net/ethernet/intel/ixgb/ixgb_main.c | 12 ++++++------
drivers/net/ethernet/intel/ixgbe/ixgbe_common.h | 4 ++--
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 12 ++++++------
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 16 ++++++++--------
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 12 ++++++------
drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c | 4 ++--
19 files changed, 72 insertions(+), 73 deletions(-)
diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
index 975eeb885ca2..11ad95f34f4f 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
@@ -1021,8 +1021,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
}
txdr->next_to_use = txdr->next_to_clean = 0;
- ew32(TDBAL, ((u64)txdr->dma & 0x00000000FFFFFFFF));
- ew32(TDBAH, ((u64)txdr->dma >> 32));
+ ew32(TDBAL, lower_32_bits(txdr->dma));
+ ew32(TDBAH, upper_32_bits(txdr->dma));
ew32(TDLEN, txdr->count * sizeof(struct e1000_tx_desc));
ew32(TDH, 0);
ew32(TDT, 0);
@@ -1081,8 +1081,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
rctl = er32(RCTL);
ew32(RCTL, rctl & ~E1000_RCTL_EN);
- ew32(RDBAL, ((u64)rxdr->dma & 0xFFFFFFFF));
- ew32(RDBAH, ((u64)rxdr->dma >> 32));
+ ew32(RDBAL, lower_32_bits(rxdr->dma));
+ ew32(RDBAH, upper_32_bits(rxdr->dma));
ew32(RDLEN, rxdr->size);
ew32(RDH, 0);
ew32(RDT, 0);
diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 93fc6c67306b..d222f731f280 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -1614,8 +1614,8 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
tdlen = adapter->tx_ring[0].count *
sizeof(struct e1000_tx_desc);
ew32(TDLEN, tdlen);
- ew32(TDBAH, (tdba >> 32));
- ew32(TDBAL, (tdba & 0x00000000ffffffffULL));
+ ew32(TDBAH, upper_32_bits(tdba));
+ ew32(TDBAL, lower_32_bits(tdba));
ew32(TDT, 0);
ew32(TDH, 0);
adapter->tx_ring[0].tdh = ((hw->mac_type >= e1000_82543) ?
@@ -1896,8 +1896,8 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
default:
rdba = adapter->rx_ring[0].dma;
ew32(RDLEN, rdlen);
- ew32(RDBAH, (rdba >> 32));
- ew32(RDBAL, (rdba & 0x00000000ffffffffULL));
+ ew32(RDBAH, upper_32_bits(rdba));
+ ew32(RDBAL, lower_32_bits(rdba));
ew32(RDT, 0);
ew32(RDH, 0);
adapter->rx_ring[0].rdh = ((hw->mac_type >= e1000_82543) ?
diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c
index 7aff68a4a4df..35304b380eaa 100644
--- a/drivers/net/ethernet/intel/e1000e/ethtool.c
+++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
@@ -1203,8 +1203,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
tx_ring->next_to_use = 0;
tx_ring->next_to_clean = 0;
- ew32(TDBAL(0), ((u64)tx_ring->dma & 0x00000000FFFFFFFF));
- ew32(TDBAH(0), ((u64)tx_ring->dma >> 32));
+ ew32(TDBAL(0), lower_32_bits(tx_ring->dma));
+ ew32(TDBAH(0), upper_32_bits(tx_ring->dma));
ew32(TDLEN(0), tx_ring->count * sizeof(struct e1000_tx_desc));
ew32(TDH(0), 0);
ew32(TDT(0), 0);
@@ -1266,8 +1266,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
rctl = er32(RCTL);
if (!(adapter->flags2 & FLAG2_NO_DISABLE_RX))
ew32(RCTL, rctl & ~E1000_RCTL_EN);
- ew32(RDBAL(0), ((u64)rx_ring->dma & 0xFFFFFFFF));
- ew32(RDBAH(0), ((u64)rx_ring->dma >> 32));
+ ew32(RDBAL(0), lower_32_bits(rx_ring->dma));
+ ew32(RDBAH(0), upper_32_bits(rx_ring->dma));
ew32(RDLEN(0), rx_ring->size);
ew32(RDH(0), 0);
ew32(RDT(0), 0);
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_common.c b/drivers/net/ethernet/intel/fm10k/fm10k_common.c
index dd95ac4f4c64..72d428f598b3 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_common.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_common.c
@@ -325,10 +325,10 @@ static void fm10k_update_hw_base_48b(struct fm10k_hw_stat *stat, u64 delta)
/* update lower 32 bits */
delta += stat->base_l;
- stat->base_l = (u32)delta;
+ stat->base_l = lower_32_bits(delta);
/* update upper 32 bits */
- stat->base_h += (u32)(delta >> 32);
+ stat->base_h += upper_32_bits(delta);
}
/**
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
index 23fb319fd2a0..e0cc9883710b 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
@@ -1548,7 +1548,7 @@ static void fm10k_rebind_hw_stats_pf(struct fm10k_hw *hw,
static void fm10k_set_dma_mask_pf(struct fm10k_hw *hw, u64 dma_mask)
{
/* we need to write the upper 32 bits of DMA mask to PhyAddrSpace */
- u32 phyaddr = (u32)(dma_mask >> 32);
+ u32 phyaddr = upper_32_bits(dma_mask);
fm10k_write_reg(hw, FM10K_PHYADDR, phyaddr);
}
diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
index 128735975caa..b184487eb49a 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_common.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
@@ -2984,8 +2984,8 @@ i40e_status i40e_aq_debug_write_register(struct i40e_hw *hw,
i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_debug_write_reg);
cmd->address = cpu_to_le32(reg_addr);
- cmd->value_high = cpu_to_le32((u32)(reg_val >> 32));
- cmd->value_low = cpu_to_le32((u32)(reg_val & 0xFFFFFFFF));
+ cmd->value_high = cpu_to_le32(upper_32_bits(reg_val));
+ cmd->value_low = cpu_to_le32(lower_32_bits(reg_val));
status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index cc1465aac2ef..091ac00053bd 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -2550,14 +2550,14 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
flow_pctype)) << 32);
i_set = i40e_get_rss_hash_bits(nfc, i_setc);
i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(0, flow_pctype),
- (u32)i_set);
+ lower_32_bits(i_set));
i40e_write_rx_ctl(hw, I40E_GLQF_HASH_INSET(1, flow_pctype),
- (u32)(i_set >> 32));
+ upper_32_bits(i_set));
hena |= BIT_ULL(flow_pctype);
}
- i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), (u32)hena);
- i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
+ i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), lower_32_bits(hena));
+ i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), upper_32_bits(hena));
i40e_flush(hw);
return 0;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index ad4cf639430e..219c696411f9 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -8410,8 +8410,8 @@ static int i40e_pf_config_rss(struct i40e_pf *pf)
((u64)i40e_read_rx_ctl(hw, I40E_PFQF_HENA(1)) << 32);
hena |= i40e_pf_get_default_rss_hena(pf);
- i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), (u32)hena);
- i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32));
+ i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), lower_32_bits(hena));
+ i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), upper_32_bits(hena));
/* Determine the RSS table size based on the hardware capabilities */
reg_val = i40e_read_rx_ctl(hw, I40E_PFQF_CTL_0);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
index 9e49ffafce28..b2566ce83505 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
@@ -88,8 +88,8 @@ static void i40e_ptp_write(struct i40e_pf *pf, const struct timespec64 *ts)
/* The timer will not update until the high register is written, so
* write the low register first.
*/
- wr32(hw, I40E_PRTTSYN_TIME_L, ns & 0xFFFFFFFF);
- wr32(hw, I40E_PRTTSYN_TIME_H, ns >> 32);
+ wr32(hw, I40E_PRTTSYN_TIME_L, lower_32_bits(ns));
+ wr32(hw, I40E_PRTTSYN_TIME_H, upper_32_bits(ns));
}
/**
@@ -141,8 +141,8 @@ static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
else
adj += diff;
- wr32(hw, I40E_PRTTSYN_INC_L, adj & 0xFFFFFFFF);
- wr32(hw, I40E_PRTTSYN_INC_H, adj >> 32);
+ wr32(hw, I40E_PRTTSYN_INC_L, lower_32_bits(adj));
+ wr32(hw, I40E_PRTTSYN_INC_H, upper_32_bits(adj));
return 0;
}
@@ -447,8 +447,8 @@ void i40e_ptp_set_increment(struct i40e_pf *pf)
* hardware will not update the clock until both registers have been
* written.
*/
- wr32(hw, I40E_PRTTSYN_INC_L, incval & 0xFFFFFFFF);
- wr32(hw, I40E_PRTTSYN_INC_H, incval >> 32);
+ wr32(hw, I40E_PRTTSYN_INC_L, lower_32_bits(incval));
+ wr32(hw, I40E_PRTTSYN_INC_H, upper_32_bits(incval));
/* Update the base adjustement value. */
ACCESS_ONCE(pf->ptp_base_adj) = incval;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 0fb899efbad3..d8cb9aea07a1 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -705,9 +705,9 @@ static int i40e_alloc_vsi_res(struct i40e_vf *vf, enum i40e_vsi_type type)
"Could not allocate VF broadcast filter\n");
spin_unlock_bh(&vsi->mac_filter_hash_lock);
i40e_write_rx_ctl(&pf->hw, I40E_VFQF_HENA1(0, vf->vf_id),
- (u32)hena);
+ lower_32_bits(hena));
i40e_write_rx_ctl(&pf->hw, I40E_VFQF_HENA1(1, vf->vf_id),
- (u32)(hena >> 32));
+ upper_32_bits(hena));
}
/* program mac filter */
@@ -2349,9 +2349,10 @@ static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg, u16 msglen)
aq_ret = I40E_ERR_PARAM;
goto err;
}
- i40e_write_rx_ctl(hw, I40E_VFQF_HENA1(0, vf->vf_id), (u32)vrh->hena);
+ i40e_write_rx_ctl(hw, I40E_VFQF_HENA1(0, vf->vf_id),
+ lower_32_bits(vrh->hena));
i40e_write_rx_ctl(hw, I40E_VFQF_HENA1(1, vf->vf_id),
- (u32)(vrh->hena >> 32));
+ upper_32_bits(vrh->hena));
/* send the response to the VF */
err:
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index c0fc53361800..089a1e87ced8 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -1379,8 +1379,8 @@ static int i40evf_init_rss(struct i40evf_adapter *adapter)
else
adapter->hena = I40E_DEFAULT_RSS_HENA;
- wr32(hw, I40E_VFQF_HENA(0), (u32)adapter->hena);
- wr32(hw, I40E_VFQF_HENA(1), (u32)(adapter->hena >> 32));
+ wr32(hw, I40E_VFQF_HENA(0), lower_32_bits(adapter->hena));
+ wr32(hw, I40E_VFQF_HENA(1), upper_32_bits(adapter->hena));
}
i40evf_fill_rss_lut(adapter);
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index a761001308dc..a2fd0b6019cf 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -3390,9 +3390,8 @@ void igb_configure_tx_ring(struct igb_adapter *adapter,
wr32(E1000_TDLEN(reg_idx),
ring->count * sizeof(union e1000_adv_tx_desc));
- wr32(E1000_TDBAL(reg_idx),
- tdba & 0x00000000ffffffffULL);
- wr32(E1000_TDBAH(reg_idx), tdba >> 32);
+ wr32(E1000_TDBAL(reg_idx), lower_32_bits(tdba));
+ wr32(E1000_TDBAH(reg_idx), upper_32_bits(tdba));
ring->tail = hw->hw_addr + E1000_TDT(reg_idx);
wr32(E1000_TDH(reg_idx), 0);
@@ -3726,9 +3725,8 @@ void igb_configure_rx_ring(struct igb_adapter *adapter,
wr32(E1000_RXDCTL(reg_idx), 0);
/* Set DMA base address registers */
- wr32(E1000_RDBAL(reg_idx),
- rdba & 0x00000000ffffffffULL);
- wr32(E1000_RDBAH(reg_idx), rdba >> 32);
+ wr32(E1000_RDBAL(reg_idx), lower_32_bits(rdba));
+ wr32(E1000_RDBAH(reg_idx), upper_32_bits(rdba));
wr32(E1000_RDLEN(reg_idx),
ring->count * sizeof(union e1000_adv_rx_desc));
diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index c4477552ce9e..67559c73e0e7 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -188,8 +188,8 @@ static void igb_ptp_systim_to_hwtstamp(struct igb_adapter *adapter,
case e1000_i211:
memset(hwtstamps, 0, sizeof(*hwtstamps));
/* Upper 32 bits contain s, lower 32 bits contain ns. */
- hwtstamps->hwtstamp = ktime_set(systim >> 32,
- systim & 0xFFFFFFFF);
+ hwtstamps->hwtstamp = ktime_set(upper_32_bits(systim),
+ lower_32_bits(systim));
break;
default:
break;
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
index 5826b1ddedcf..a23e99528d5e 100644
--- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c
+++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
@@ -749,8 +749,8 @@ ixgb_configure_tx(struct ixgb_adapter *adapter)
* tx_ring.dma can be either a 32 or 64 bit value
*/
- IXGB_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
- IXGB_WRITE_REG(hw, TDBAH, (tdba >> 32));
+ IXGB_WRITE_REG(hw, TDBAL, lower_32_bits(tdba));
+ IXGB_WRITE_REG(hw, TDBAH, upper_32_bits(tdba));
IXGB_WRITE_REG(hw, TDLEN, tdlen);
@@ -875,8 +875,8 @@ ixgb_configure_rx(struct ixgb_adapter *adapter)
/* Setup the Base and Length of the Rx Descriptor Ring */
- IXGB_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
- IXGB_WRITE_REG(hw, RDBAH, (rdba >> 32));
+ IXGB_WRITE_REG(hw, RDBAL, lower_32_bits(rdba));
+ IXGB_WRITE_REG(hw, RDBAH, upper_32_bits(rdba));
IXGB_WRITE_REG(hw, RDLEN, rdlen);
@@ -1664,8 +1664,8 @@ ixgb_update_stats(struct ixgb_adapter *adapter)
if (multi >= bcast)
multi -= bcast;
- adapter->stats.mprcl += (multi & 0xFFFFFFFF);
- adapter->stats.mprch += (multi >> 32);
+ adapter->stats.mprcl += lower_32_bits(multi);
+ adapter->stats.mprch += upper_32_bits(multi);
adapter->stats.bprcl += bcast_l;
adapter->stats.bprch += bcast_h;
} else {
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
index e083732adf64..6237e6c2ed30 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
@@ -173,8 +173,8 @@ static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
#define writeq writeq
static inline void writeq(u64 val, void __iomem *addr)
{
- writel((u32)val, addr);
- writel((u32)(val >> 32), addr + 4);
+ writel(lower_32_bits(val), addr);
+ writel(upper_32_bits(val), addr + 4);
}
#endif
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 17589068da78..0d973e2d0937 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -748,10 +748,10 @@ static void ixgbe_get_regs(struct net_device *netdev,
regs_buff[939] = IXGBE_GET_STAT(adapter, bprc);
regs_buff[940] = IXGBE_GET_STAT(adapter, mprc);
regs_buff[941] = IXGBE_GET_STAT(adapter, gptc);
- regs_buff[942] = (u32)IXGBE_GET_STAT(adapter, gorc);
- regs_buff[943] = (u32)(IXGBE_GET_STAT(adapter, gorc) >> 32);
- regs_buff[944] = (u32)IXGBE_GET_STAT(adapter, gotc);
- regs_buff[945] = (u32)(IXGBE_GET_STAT(adapter, gotc) >> 32);
+ regs_buff[942] = lower_32_bits(IXGBE_GET_STAT(adapter, gorc));
+ regs_buff[943] = upper_32_bits(IXGBE_GET_STAT(adapter, gorc));
+ regs_buff[944] = lower_32_bits(IXGBE_GET_STAT(adapter, gotc));
+ regs_buff[945] = upper_32_bits(IXGBE_GET_STAT(adapter, gotc));
for (i = 0; i < 8; i++)
regs_buff[946 + i] = IXGBE_GET_STAT(adapter, rnbc[i]);
regs_buff[954] = IXGBE_GET_STAT(adapter, ruc);
@@ -761,8 +761,8 @@ static void ixgbe_get_regs(struct net_device *netdev,
regs_buff[958] = IXGBE_GET_STAT(adapter, mngprc);
regs_buff[959] = IXGBE_GET_STAT(adapter, mngpdc);
regs_buff[960] = IXGBE_GET_STAT(adapter, mngptc);
- regs_buff[961] = (u32)IXGBE_GET_STAT(adapter, tor);
- regs_buff[962] = (u32)(IXGBE_GET_STAT(adapter, tor) >> 32);
+ regs_buff[961] = lower_32_bits(IXGBE_GET_STAT(adapter, tor));
+ regs_buff[962] = upper_32_bits(IXGBE_GET_STAT(adapter, tor));
regs_buff[963] = IXGBE_GET_STAT(adapter, tpr);
regs_buff[964] = IXGBE_GET_STAT(adapter, tpt);
regs_buff[965] = IXGBE_GET_STAT(adapter, ptc64);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 0c6eca570791..71d054f6a2aa 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -936,10 +936,10 @@ static inline void ixgbe_irq_rearm_queues(struct ixgbe_adapter *adapter,
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
case ixgbe_mac_x550em_a:
- mask = (qmask & 0xFFFFFFFF);
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(0), mask);
- mask = (qmask >> 32);
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(1), mask);
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(0),
+ lower_32_bits(qmask));
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(1),
+ upper_32_bits(qmask));
break;
default:
break;
@@ -2650,10 +2650,10 @@ static inline void ixgbe_irq_enable_queues(struct ixgbe_adapter *adapter,
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
case ixgbe_mac_x550em_a:
- mask = (qmask & 0xFFFFFFFF);
+ mask = lower_32_bits(qmask);
if (mask)
IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
- mask = (qmask >> 32);
+ mask = upper_32_bits(qmask);
if (mask)
IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
break;
@@ -2679,10 +2679,10 @@ static inline void ixgbe_irq_disable_queues(struct ixgbe_adapter *adapter,
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
case ixgbe_mac_x550em_a:
- mask = (qmask & 0xFFFFFFFF);
+ mask = lower_32_bits(qmask);
if (mask)
IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), mask);
- mask = (qmask >> 32);
+ mask = upper_32_bits(qmask);
if (mask)
IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), mask);
break;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
index ef0635e0918c..a1cb0b99456c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
@@ -206,8 +206,8 @@ static void ixgbe_ptp_setup_sdp_x540(struct ixgbe_adapter *adapter)
IXGBE_TSAUXC_SDP0_INT;
/* clock period (or pulse length) */
- clktiml = (u32)(IXGBE_PTP_PPS_HALF_SECOND << shift);
- clktimh = (u32)((IXGBE_PTP_PPS_HALF_SECOND << shift) >> 32);
+ clktiml = lower_32_bits(IXGBE_PTP_PPS_HALF_SECOND << shift);
+ clktimh = upper_32_bits(IXGBE_PTP_PPS_HALF_SECOND << shift);
/* Account for the cyclecounter wrap-around value by
* using the converted ns value of the current time to
@@ -221,8 +221,8 @@ static void ixgbe_ptp_setup_sdp_x540(struct ixgbe_adapter *adapter)
clock_edge += ((IXGBE_PTP_PPS_HALF_SECOND - (u64)rem) << shift);
/* specify the initial clock start time */
- trgttiml = (u32)clock_edge;
- trgttimh = (u32)(clock_edge >> 32);
+ trgttiml = lower_32_bits(clock_edge);
+ trgttimh = upper_32_bits(clock_edge);
IXGBE_WRITE_REG(hw, IXGBE_CLKTIML, clktiml);
IXGBE_WRITE_REG(hw, IXGBE_CLKTIMH, clktimh);
@@ -339,8 +339,8 @@ static void ixgbe_ptp_convert_to_hwtstamp(struct ixgbe_adapter *adapter,
* correct math even though the units haven't been corrected
* yet.
*/
- systime.tv_sec = timestamp >> 32;
- systime.tv_nsec = timestamp & 0xFFFFFFFF;
+ systime.tv_sec = upper_32_bits(timestamp);
+ systime.tv_nsec = lower_32_bits(timestamp);
timestamp = timespec64_to_ns(&systime);
break;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
index 200f847fd8f3..1d3ca7a5106f 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
@@ -3437,8 +3437,8 @@ static void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw,
else
pfflp &= ~(1ULL << pool);
- IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
- IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
+ IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, lower_32_bits(pfflp));
+ IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, upper_32_bits(pfflp));
}
/**
--
2.10.0.rc2.1.g053435c
^ permalink raw reply related
* Re: [PATCH net-next] mdio: Demote print from info to debug in mdio_device_register
From: Andrew Lunn @ 2017-01-07 18:17 UTC (permalink / raw)
To: Florian Fainelli; +Cc: netdev, davem
In-Reply-To: <20170107062759.32015-1-f.fainelli@gmail.com>
On Fri, Jan 06, 2017 at 10:27:59PM -0800, Florian Fainelli wrote:
> While it is useful to know which MDIO device is being registered, demote
> the dev_info() to a dev_dbg().
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox