Skip to content

Commit 7324880

Browse files
committed
Merge tag 'mlx5-fixes-2019-04-09' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== Mellanox, mlx5 fixes 2019-04-09 This series provides some fixes to mlx5 driver. I've cc'ed some of the checksum fixes to Eric Dumazet and i would like to get his feedback before you pull. For -stable v4.19 ('net/mlx5: FPGA, tls, idr remove on flow delete') ('net/mlx5: FPGA, tls, hold rcu read lock a bit longer') For -stable v4.20 ('net/mlx5e: Rx, Check ip headers sanity') ('Revert "net/mlx5e: Enable reporting checksum unnecessary also for L3 packets"') ('net/mlx5e: Rx, Fixup skb checksum for packets with tail padding') For -stable v5.0 ('net/mlx5e: Switch to Toeplitz RSS hash by default') ('net/mlx5e: Protect against non-uplink representor for encap') ('net/mlx5e: XDP, Avoid checksum complete when XDP prog is loaded') ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 69f23a0 + 7ee2ace commit 7324880

File tree

9 files changed

+140
-65
lines changed

9 files changed

+140
-65
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ void mlx5e_close_channels(struct mlx5e_channels *chs);
858858
* switching channels
859859
*/
860860
typedef int (*mlx5e_fp_hw_modify)(struct mlx5e_priv *priv);
861+
int mlx5e_safe_reopen_channels(struct mlx5e_priv *priv);
861862
int mlx5e_safe_switch_channels(struct mlx5e_priv *priv,
862863
struct mlx5e_channels *new_chs,
863864
mlx5e_fp_hw_modify hw_modify);

drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,17 @@ static int mlx5e_tx_reporter_recover_from_ctx(struct mlx5e_tx_err_ctx *err_ctx)
186186

187187
static int mlx5e_tx_reporter_recover_all(struct mlx5e_priv *priv)
188188
{
189-
int err;
189+
int err = 0;
190190

191191
rtnl_lock();
192192
mutex_lock(&priv->state_lock);
193-
mlx5e_close_locked(priv->netdev);
194-
err = mlx5e_open_locked(priv->netdev);
193+
194+
if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
195+
goto out;
196+
197+
err = mlx5e_safe_reopen_channels(priv);
198+
199+
out:
195200
mutex_unlock(&priv->state_lock);
196201
rtnl_unlock();
197202

drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,
3939
return -EOPNOTSUPP;
4040
}
4141

42+
if (!(mlx5e_eswitch_rep(*out_dev) &&
43+
mlx5e_is_uplink_rep(netdev_priv(*out_dev))))
44+
return -EOPNOTSUPP;
45+
4246
return 0;
4347
}
4448

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,8 @@ static int set_pflag_rx_no_csum_complete(struct net_device *netdev, bool enable)
17681768
struct mlx5e_channel *c;
17691769
int i;
17701770

1771-
if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
1771+
if (!test_bit(MLX5E_STATE_OPENED, &priv->state) ||
1772+
priv->channels.params.xdp_prog)
17721773
return 0;
17731774

17741775
for (i = 0; i < channels->num; i++) {

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,11 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,
951951
if (params->rx_dim_enabled)
952952
__set_bit(MLX5E_RQ_STATE_AM, &c->rq.state);
953953

954-
if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_NO_CSUM_COMPLETE))
954+
/* We disable csum_complete when XDP is enabled since
955+
* XDP programs might manipulate packets which will render
956+
* skb->checksum incorrect.
957+
*/
958+
if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_NO_CSUM_COMPLETE) || c->xdp)
955959
__set_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &c->rq.state);
956960

957961
return 0;
@@ -2937,6 +2941,14 @@ int mlx5e_safe_switch_channels(struct mlx5e_priv *priv,
29372941
return 0;
29382942
}
29392943

2944+
int mlx5e_safe_reopen_channels(struct mlx5e_priv *priv)
2945+
{
2946+
struct mlx5e_channels new_channels = {};
2947+
2948+
new_channels.params = priv->channels.params;
2949+
return mlx5e_safe_switch_channels(priv, &new_channels, NULL);
2950+
}
2951+
29402952
void mlx5e_timestamp_init(struct mlx5e_priv *priv)
29412953
{
29422954
priv->tstamp.tx_type = HWTSTAMP_TX_OFF;
@@ -4161,11 +4173,10 @@ static void mlx5e_tx_timeout_work(struct work_struct *work)
41614173
if (!report_failed)
41624174
goto unlock;
41634175

4164-
mlx5e_close_locked(priv->netdev);
4165-
err = mlx5e_open_locked(priv->netdev);
4176+
err = mlx5e_safe_reopen_channels(priv);
41664177
if (err)
41674178
netdev_err(priv->netdev,
4168-
"mlx5e_open_locked failed recovering from a tx_timeout, err(%d).\n",
4179+
"mlx5e_safe_reopen_channels failed recovering from a tx_timeout, err(%d).\n",
41694180
err);
41704181

41714182
unlock:
@@ -4553,7 +4564,7 @@ void mlx5e_build_rss_params(struct mlx5e_rss_params *rss_params,
45534564
{
45544565
enum mlx5e_traffic_types tt;
45554566

4556-
rss_params->hfunc = ETH_RSS_HASH_XOR;
4567+
rss_params->hfunc = ETH_RSS_HASH_TOP;
45574568
netdev_rss_key_fill(rss_params->toeplitz_hash_key,
45584569
sizeof(rss_params->toeplitz_hash_key));
45594570
mlx5e_build_default_indir_rqt(rss_params->indirection_rqt,

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

Lines changed: 75 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,14 @@ static inline bool is_last_ethertype_ip(struct sk_buff *skb, int *network_depth,
692692
{
693693
*proto = ((struct ethhdr *)skb->data)->h_proto;
694694
*proto = __vlan_get_protocol(skb, *proto, network_depth);
695-
return (*proto == htons(ETH_P_IP) || *proto == htons(ETH_P_IPV6));
695+
696+
if (*proto == htons(ETH_P_IP))
697+
return pskb_may_pull(skb, *network_depth + sizeof(struct iphdr));
698+
699+
if (*proto == htons(ETH_P_IPV6))
700+
return pskb_may_pull(skb, *network_depth + sizeof(struct ipv6hdr));
701+
702+
return false;
696703
}
697704

698705
static inline void mlx5e_enable_ecn(struct mlx5e_rq *rq, struct sk_buff *skb)
@@ -712,17 +719,6 @@ static inline void mlx5e_enable_ecn(struct mlx5e_rq *rq, struct sk_buff *skb)
712719
rq->stats->ecn_mark += !!rc;
713720
}
714721

715-
static u32 mlx5e_get_fcs(const struct sk_buff *skb)
716-
{
717-
const void *fcs_bytes;
718-
u32 _fcs_bytes;
719-
720-
fcs_bytes = skb_header_pointer(skb, skb->len - ETH_FCS_LEN,
721-
ETH_FCS_LEN, &_fcs_bytes);
722-
723-
return __get_unaligned_cpu32(fcs_bytes);
724-
}
725-
726722
static u8 get_ip_proto(struct sk_buff *skb, int network_depth, __be16 proto)
727723
{
728724
void *ip_p = skb->data + network_depth;
@@ -733,6 +729,68 @@ static u8 get_ip_proto(struct sk_buff *skb, int network_depth, __be16 proto)
733729

734730
#define short_frame(size) ((size) <= ETH_ZLEN + ETH_FCS_LEN)
735731

732+
#define MAX_PADDING 8
733+
734+
static void
735+
tail_padding_csum_slow(struct sk_buff *skb, int offset, int len,
736+
struct mlx5e_rq_stats *stats)
737+
{
738+
stats->csum_complete_tail_slow++;
739+
skb->csum = csum_block_add(skb->csum,
740+
skb_checksum(skb, offset, len, 0),
741+
offset);
742+
}
743+
744+
static void
745+
tail_padding_csum(struct sk_buff *skb, int offset,
746+
struct mlx5e_rq_stats *stats)
747+
{
748+
u8 tail_padding[MAX_PADDING];
749+
int len = skb->len - offset;
750+
void *tail;
751+
752+
if (unlikely(len > MAX_PADDING)) {
753+
tail_padding_csum_slow(skb, offset, len, stats);
754+
return;
755+
}
756+
757+
tail = skb_header_pointer(skb, offset, len, tail_padding);
758+
if (unlikely(!tail)) {
759+
tail_padding_csum_slow(skb, offset, len, stats);
760+
return;
761+
}
762+
763+
stats->csum_complete_tail++;
764+
skb->csum = csum_block_add(skb->csum, csum_partial(tail, len, 0), offset);
765+
}
766+
767+
static void
768+
mlx5e_skb_padding_csum(struct sk_buff *skb, int network_depth, __be16 proto,
769+
struct mlx5e_rq_stats *stats)
770+
{
771+
struct ipv6hdr *ip6;
772+
struct iphdr *ip4;
773+
int pkt_len;
774+
775+
switch (proto) {
776+
case htons(ETH_P_IP):
777+
ip4 = (struct iphdr *)(skb->data + network_depth);
778+
pkt_len = network_depth + ntohs(ip4->tot_len);
779+
break;
780+
case htons(ETH_P_IPV6):
781+
ip6 = (struct ipv6hdr *)(skb->data + network_depth);
782+
pkt_len = network_depth + sizeof(*ip6) + ntohs(ip6->payload_len);
783+
break;
784+
default:
785+
return;
786+
}
787+
788+
if (likely(pkt_len >= skb->len))
789+
return;
790+
791+
tail_padding_csum(skb, pkt_len, stats);
792+
}
793+
736794
static inline void mlx5e_handle_csum(struct net_device *netdev,
737795
struct mlx5_cqe64 *cqe,
738796
struct mlx5e_rq *rq,
@@ -752,7 +810,8 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
752810
return;
753811
}
754812

755-
if (unlikely(test_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &rq->state)))
813+
/* True when explicitly set via priv flag, or XDP prog is loaded */
814+
if (test_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &rq->state))
756815
goto csum_unnecessary;
757816

758817
/* CQE csum doesn't cover padding octets in short ethernet
@@ -780,18 +839,15 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
780839
skb->csum = csum_partial(skb->data + ETH_HLEN,
781840
network_depth - ETH_HLEN,
782841
skb->csum);
783-
if (unlikely(netdev->features & NETIF_F_RXFCS))
784-
skb->csum = csum_block_add(skb->csum,
785-
(__force __wsum)mlx5e_get_fcs(skb),
786-
skb->len - ETH_FCS_LEN);
842+
843+
mlx5e_skb_padding_csum(skb, network_depth, proto, stats);
787844
stats->csum_complete++;
788845
return;
789846
}
790847

791848
csum_unnecessary:
792849
if (likely((cqe->hds_ip_ext & CQE_L3_OK) &&
793-
((cqe->hds_ip_ext & CQE_L4_OK) ||
794-
(get_cqe_l4_hdr_type(cqe) == CQE_L4_HDR_TYPE_NONE)))) {
850+
(cqe->hds_ip_ext & CQE_L4_OK))) {
795851
skb->ip_summed = CHECKSUM_UNNECESSARY;
796852
if (cqe_is_tunneled(cqe)) {
797853
skb->csum_level = 1;

drivers/net/ethernet/mellanox/mlx5/core/en_stats.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ static const struct counter_desc sw_stats_desc[] = {
5959
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary) },
6060
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_none) },
6161
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete) },
62+
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete_tail) },
63+
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete_tail_slow) },
6264
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary_inner) },
6365
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_drop) },
6466
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_redirect) },
@@ -151,6 +153,8 @@ static void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv)
151153
s->rx_removed_vlan_packets += rq_stats->removed_vlan_packets;
152154
s->rx_csum_none += rq_stats->csum_none;
153155
s->rx_csum_complete += rq_stats->csum_complete;
156+
s->rx_csum_complete_tail += rq_stats->csum_complete_tail;
157+
s->rx_csum_complete_tail_slow += rq_stats->csum_complete_tail_slow;
154158
s->rx_csum_unnecessary += rq_stats->csum_unnecessary;
155159
s->rx_csum_unnecessary_inner += rq_stats->csum_unnecessary_inner;
156160
s->rx_xdp_drop += rq_stats->xdp_drop;
@@ -1190,6 +1194,8 @@ static const struct counter_desc rq_stats_desc[] = {
11901194
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, packets) },
11911195
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, bytes) },
11921196
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete) },
1197+
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete_tail) },
1198+
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete_tail_slow) },
11931199
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary) },
11941200
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary_inner) },
11951201
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_none) },

drivers/net/ethernet/mellanox/mlx5/core/en_stats.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ struct mlx5e_sw_stats {
7171
u64 rx_csum_unnecessary;
7272
u64 rx_csum_none;
7373
u64 rx_csum_complete;
74+
u64 rx_csum_complete_tail;
75+
u64 rx_csum_complete_tail_slow;
7476
u64 rx_csum_unnecessary_inner;
7577
u64 rx_xdp_drop;
7678
u64 rx_xdp_redirect;
@@ -181,6 +183,8 @@ struct mlx5e_rq_stats {
181183
u64 packets;
182184
u64 bytes;
183185
u64 csum_complete;
186+
u64 csum_complete_tail;
187+
u64 csum_complete_tail_slow;
184188
u64 csum_unnecessary;
185189
u64 csum_unnecessary_inner;
186190
u64 csum_none;

0 commit comments

Comments
 (0)