Commit 24c22dd0 authored by Aya Levin's avatar Aya Levin Committed by Saeed Mahameed

net/mlx5e: Add states to PTP channel

Add PTP TX state to PTP channel, which indicates the corresponding SQ is
available. Further patches in the set extend PTP channel to include RQ.
The PTP channel state will be used for separation and coexistence of RX
and TX PTP. Enhance conditions to verify the TX PTP state is set.
Signed-off-by: default avatarAya Levin <ayal@nvidia.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent d0922bf7
...@@ -134,9 +134,11 @@ static int mlx5e_ptp_napi_poll(struct napi_struct *napi, int budget) ...@@ -134,9 +134,11 @@ static int mlx5e_ptp_napi_poll(struct napi_struct *napi, int budget)
ch_stats->poll++; ch_stats->poll++;
for (i = 0; i < c->num_tc; i++) { if (test_bit(MLX5E_PTP_STATE_TX, c->state)) {
busy |= mlx5e_poll_tx_cq(&c->ptpsq[i].txqsq.cq, budget); for (i = 0; i < c->num_tc; i++) {
busy |= mlx5e_ptp_poll_ts_cq(&c->ptpsq[i].ts_cq, budget); busy |= mlx5e_poll_tx_cq(&c->ptpsq[i].txqsq.cq, budget);
busy |= mlx5e_ptp_poll_ts_cq(&c->ptpsq[i].ts_cq, budget);
}
} }
if (busy) { if (busy) {
...@@ -149,9 +151,11 @@ static int mlx5e_ptp_napi_poll(struct napi_struct *napi, int budget) ...@@ -149,9 +151,11 @@ static int mlx5e_ptp_napi_poll(struct napi_struct *napi, int budget)
ch_stats->arm++; ch_stats->arm++;
for (i = 0; i < c->num_tc; i++) { if (test_bit(MLX5E_PTP_STATE_TX, c->state)) {
mlx5e_cq_arm(&c->ptpsq[i].txqsq.cq); for (i = 0; i < c->num_tc; i++) {
mlx5e_cq_arm(&c->ptpsq[i].ts_cq); mlx5e_cq_arm(&c->ptpsq[i].txqsq.cq);
mlx5e_cq_arm(&c->ptpsq[i].ts_cq);
}
} }
out: out:
...@@ -422,9 +426,10 @@ static void mlx5e_ptp_build_params(struct mlx5e_ptp *c, ...@@ -422,9 +426,10 @@ static void mlx5e_ptp_build_params(struct mlx5e_ptp *c,
params->num_tc = orig->num_tc; params->num_tc = orig->num_tc;
/* SQ */ /* SQ */
params->log_sq_size = orig->log_sq_size; if (test_bit(MLX5E_PTP_STATE_TX, c->state)) {
params->log_sq_size = orig->log_sq_size;
mlx5e_ptp_build_sq_param(c->mdev, params, &cparams->txq_sq_param); mlx5e_ptp_build_sq_param(c->mdev, params, &cparams->txq_sq_param);
}
} }
static int mlx5e_ptp_open_queues(struct mlx5e_ptp *c, static int mlx5e_ptp_open_queues(struct mlx5e_ptp *c,
...@@ -432,26 +437,38 @@ static int mlx5e_ptp_open_queues(struct mlx5e_ptp *c, ...@@ -432,26 +437,38 @@ static int mlx5e_ptp_open_queues(struct mlx5e_ptp *c,
{ {
int err; int err;
err = mlx5e_ptp_open_cqs(c, cparams); if (test_bit(MLX5E_PTP_STATE_TX, c->state)) {
if (err) err = mlx5e_ptp_open_cqs(c, cparams);
return err; if (err)
return err;
err = mlx5e_ptp_open_txqsqs(c, cparams);
if (err)
goto close_cqs;
err = mlx5e_ptp_open_txqsqs(c, cparams);
if (err)
goto close_cqs;
}
return 0; return 0;
close_cqs: close_cqs:
mlx5e_ptp_close_cqs(c); if (test_bit(MLX5E_PTP_STATE_TX, c->state))
mlx5e_ptp_close_cqs(c);
return err; return err;
} }
static void mlx5e_ptp_close_queues(struct mlx5e_ptp *c) static void mlx5e_ptp_close_queues(struct mlx5e_ptp *c)
{ {
mlx5e_ptp_close_txqsqs(c); if (test_bit(MLX5E_PTP_STATE_TX, c->state)) {
mlx5e_ptp_close_cqs(c); mlx5e_ptp_close_txqsqs(c);
mlx5e_ptp_close_cqs(c);
}
}
static int mlx5e_ptp_set_state(struct mlx5e_ptp *c, struct mlx5e_params *params)
{
if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_TX_PORT_TS))
__set_bit(MLX5E_PTP_STATE_TX, c->state);
return bitmap_empty(c->state, MLX5E_PTP_STATE_NUM_STATES) ? -EINVAL : 0;
} }
int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params, int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
...@@ -479,6 +496,10 @@ int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params, ...@@ -479,6 +496,10 @@ int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
c->stats = &priv->ptp_stats.ch; c->stats = &priv->ptp_stats.ch;
c->lag_port = lag_port; c->lag_port = lag_port;
err = mlx5e_ptp_set_state(c, params);
if (err)
goto err_free;
netif_napi_add(netdev, &c->napi, mlx5e_ptp_napi_poll, 64); netif_napi_add(netdev, &c->napi, mlx5e_ptp_napi_poll, 64);
mlx5e_ptp_build_params(c, cparams, params); mlx5e_ptp_build_params(c, cparams, params);
...@@ -495,7 +516,7 @@ int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params, ...@@ -495,7 +516,7 @@ int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
err_napi_del: err_napi_del:
netif_napi_del(&c->napi); netif_napi_del(&c->napi);
err_free:
kvfree(cparams); kvfree(cparams);
kvfree(c); kvfree(c);
return err; return err;
...@@ -515,16 +536,20 @@ void mlx5e_ptp_activate_channel(struct mlx5e_ptp *c) ...@@ -515,16 +536,20 @@ void mlx5e_ptp_activate_channel(struct mlx5e_ptp *c)
napi_enable(&c->napi); napi_enable(&c->napi);
for (tc = 0; tc < c->num_tc; tc++) if (test_bit(MLX5E_PTP_STATE_TX, c->state)) {
mlx5e_activate_txqsq(&c->ptpsq[tc].txqsq); for (tc = 0; tc < c->num_tc; tc++)
mlx5e_activate_txqsq(&c->ptpsq[tc].txqsq);
}
} }
void mlx5e_ptp_deactivate_channel(struct mlx5e_ptp *c) void mlx5e_ptp_deactivate_channel(struct mlx5e_ptp *c)
{ {
int tc; int tc;
for (tc = 0; tc < c->num_tc; tc++) if (test_bit(MLX5E_PTP_STATE_TX, c->state)) {
mlx5e_deactivate_txqsq(&c->ptpsq[tc].txqsq); for (tc = 0; tc < c->num_tc; tc++)
mlx5e_deactivate_txqsq(&c->ptpsq[tc].txqsq);
}
napi_disable(&c->napi); napi_disable(&c->napi);
} }
...@@ -16,6 +16,11 @@ struct mlx5e_ptpsq { ...@@ -16,6 +16,11 @@ struct mlx5e_ptpsq {
struct mlx5e_ptp_cq_stats *cq_stats; struct mlx5e_ptp_cq_stats *cq_stats;
}; };
enum {
MLX5E_PTP_STATE_TX,
MLX5E_PTP_STATE_NUM_STATES,
};
struct mlx5e_ptp { struct mlx5e_ptp {
/* data path */ /* data path */
struct mlx5e_ptpsq ptpsq[MLX5E_MAX_NUM_TC]; struct mlx5e_ptpsq ptpsq[MLX5E_MAX_NUM_TC];
...@@ -33,6 +38,7 @@ struct mlx5e_ptp { ...@@ -33,6 +38,7 @@ struct mlx5e_ptp {
struct mlx5e_priv *priv; struct mlx5e_priv *priv;
struct mlx5_core_dev *mdev; struct mlx5_core_dev *mdev;
struct hwtstamp_config *tstamp; struct hwtstamp_config *tstamp;
DECLARE_BITMAP(state, MLX5E_PTP_STATE_NUM_STATES);
}; };
int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params, int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
......
...@@ -304,6 +304,7 @@ mlx5e_tx_reporter_diagnose_common_config(struct devlink_health_reporter *reporte ...@@ -304,6 +304,7 @@ mlx5e_tx_reporter_diagnose_common_config(struct devlink_health_reporter *reporte
{ {
struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter); struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter);
struct mlx5e_txqsq *generic_sq = priv->txq2sq[0]; struct mlx5e_txqsq *generic_sq = priv->txq2sq[0];
struct mlx5e_ptp *ptp_ch = priv->channels.ptp;
struct mlx5e_ptpsq *generic_ptpsq; struct mlx5e_ptpsq *generic_ptpsq;
int err; int err;
...@@ -315,12 +316,11 @@ mlx5e_tx_reporter_diagnose_common_config(struct devlink_health_reporter *reporte ...@@ -315,12 +316,11 @@ mlx5e_tx_reporter_diagnose_common_config(struct devlink_health_reporter *reporte
if (err) if (err)
return err; return err;
generic_ptpsq = priv->channels.ptp ? if (!ptp_ch || !test_bit(MLX5E_PTP_STATE_TX, ptp_ch->state))
&priv->channels.ptp->ptpsq[0] :
NULL;
if (!generic_ptpsq)
goto out; goto out;
generic_ptpsq = &ptp_ch->ptpsq[0];
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "PTP"); err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "PTP");
if (err) if (err)
return err; return err;
...@@ -375,7 +375,7 @@ static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter, ...@@ -375,7 +375,7 @@ static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter,
} }
} }
if (!ptp_ch) if (!ptp_ch || !test_bit(MLX5E_PTP_STATE_TX, ptp_ch->state))
goto close_sqs_nest; goto close_sqs_nest;
for (tc = 0; tc < priv->channels.params.num_tc; tc++) { for (tc = 0; tc < priv->channels.params.num_tc; tc++) {
...@@ -497,7 +497,7 @@ static int mlx5e_tx_reporter_dump_all_sqs(struct mlx5e_priv *priv, ...@@ -497,7 +497,7 @@ static int mlx5e_tx_reporter_dump_all_sqs(struct mlx5e_priv *priv,
} }
} }
if (ptp_ch) { if (ptp_ch && test_bit(MLX5E_PTP_STATE_TX, ptp_ch->state)) {
for (tc = 0; tc < priv->channels.params.num_tc; tc++) { for (tc = 0; tc < priv->channels.params.num_tc; tc++) {
struct mlx5e_txqsq *sq = &ptp_ch->ptpsq[tc].txqsq; struct mlx5e_txqsq *sq = &ptp_ch->ptpsq[tc].txqsq;
......
...@@ -2759,6 +2759,9 @@ static void mlx5e_build_txq_maps(struct mlx5e_priv *priv) ...@@ -2759,6 +2759,9 @@ static void mlx5e_build_txq_maps(struct mlx5e_priv *priv)
if (!priv->channels.ptp) if (!priv->channels.ptp)
return; return;
if (!test_bit(MLX5E_PTP_STATE_TX, priv->channels.ptp->state))
return;
for (tc = 0; tc < num_tc; tc++) { for (tc = 0; tc < num_tc; tc++) {
struct mlx5e_ptp *c = priv->channels.ptp; struct mlx5e_ptp *c = priv->channels.ptp;
struct mlx5e_txqsq *sq = &c->ptpsq[tc].txqsq; struct mlx5e_txqsq *sq = &c->ptpsq[tc].txqsq;
......
...@@ -133,6 +133,8 @@ u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb, ...@@ -133,6 +133,8 @@ u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb,
/* Sync with mlx5e_update_num_tc_x_num_ch - avoid refetching. */ /* Sync with mlx5e_update_num_tc_x_num_ch - avoid refetching. */
num_tc_x_num_ch = READ_ONCE(priv->num_tc_x_num_ch); num_tc_x_num_ch = READ_ONCE(priv->num_tc_x_num_ch);
if (unlikely(dev->real_num_tx_queues > num_tc_x_num_ch)) { if (unlikely(dev->real_num_tx_queues > num_tc_x_num_ch)) {
struct mlx5e_ptp *ptp_channel;
/* Order maj_id before defcls - pairs with mlx5e_htb_root_add. */ /* Order maj_id before defcls - pairs with mlx5e_htb_root_add. */
u16 htb_maj_id = smp_load_acquire(&priv->htb.maj_id); u16 htb_maj_id = smp_load_acquire(&priv->htb.maj_id);
...@@ -142,10 +144,11 @@ u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb, ...@@ -142,10 +144,11 @@ u16 mlx5e_select_queue(struct net_device *dev, struct sk_buff *skb,
return txq_ix; return txq_ix;
} }
if (unlikely(priv->channels.ptp)) ptp_channel = READ_ONCE(priv->channels.ptp);
if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && if (unlikely(ptp_channel) &&
mlx5e_use_ptpsq(skb)) test_bit(MLX5E_PTP_STATE_TX, ptp_channel->state) &&
return mlx5e_select_ptpsq(dev, skb); mlx5e_use_ptpsq(skb))
return mlx5e_select_ptpsq(dev, skb);
txq_ix = netdev_pick_tx(dev, skb, NULL); txq_ix = netdev_pick_tx(dev, skb, NULL);
/* Fix netdev_pick_tx() not to choose ptp_channel and HTB txqs. /* Fix netdev_pick_tx() not to choose ptp_channel and HTB txqs.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment