net/mlx5e: Non-atomic indicator for ring enabled state
authorTariq Toukan <tariqt@mellanox.com>
Mon, 3 Jul 2017 08:27:20 +0000 (11:27 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Sun, 3 Sep 2017 03:34:09 +0000 (06:34 +0300)
Rings enabled state change occurs in control path only, and is always
followed by a napi_sychronize(), so that following NAPIs read the
new value. This read does not need to be atomic.

The RQ auto-moderation bit is not set/cleared in data-path.
No need for atomic read, a regular read operation is sufficient.
In RQ creation time as well, there's no multiple threads trying
to access it yet, hence a regular read can be used.

Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c

index ce8b4f648757a2ed78baa5f7051bd1a80bd6a8ca..0c4f1f30085aa845718f150d0e33187e07074869 100644 (file)
@@ -295,6 +295,8 @@ enum {
        MLX5E_RQ_STATE_AM,
 };
 
+#define MLX5E_TEST_BIT(state, nr) (state & BIT(nr))
+
 struct mlx5e_cq {
        /* data path - accessed per cqe */
        struct mlx5_cqwq           wq;
index 5aa4681f7c3c283a52c015c47fadb1cba753fe2a..411fb68794bcd60572657fcb9cf35e73301a7510 100644 (file)
@@ -929,7 +929,7 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,
                goto err_destroy_rq;
 
        if (params->rx_am_enabled)
-               set_bit(MLX5E_RQ_STATE_AM, &c->rq.state);
+               c->rq.state |= BIT(MLX5E_RQ_STATE_AM);
 
        return 0;
 
index 9d9c13ae6b83475b9c2579afe6093b034c035c08..a5522c3992a25e500be8e1802d5da5384b2b84bc 100644 (file)
@@ -424,7 +424,7 @@ void mlx5e_post_rx_mpwqe(struct mlx5e_rq *rq)
 
        clear_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state);
 
-       if (unlikely(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state))) {
+       if (unlikely(!MLX5E_TEST_BIT(rq->state, MLX5E_RQ_STATE_ENABLED))) {
                mlx5e_free_rx_mpwqe(rq, &rq->mpwqe.info[wq->head]);
                return;
        }
@@ -461,7 +461,7 @@ bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq)
        struct mlx5_wq_ll *wq = &rq->wq;
        int err;
 
-       if (unlikely(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state)))
+       if (unlikely(!MLX5E_TEST_BIT(rq->state, MLX5E_RQ_STATE_ENABLED)))
                return false;
 
        if (mlx5_wq_ll_is_full(wq))
@@ -983,7 +983,7 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
        struct mlx5_cqe64 *cqe;
        int work_done = 0;
 
-       if (unlikely(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state)))
+       if (unlikely(!MLX5E_TEST_BIT(rq->state, MLX5E_RQ_STATE_ENABLED)))
                return 0;
 
        if (cq->decmprs_left)
@@ -1031,7 +1031,7 @@ bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq)
 
        sq = container_of(cq, struct mlx5e_xdpsq, cq);
 
-       if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
+       if (unlikely(!MLX5E_TEST_BIT(sq->state, MLX5E_SQ_STATE_ENABLED)))
                return false;
 
        cqe = mlx5_cqwq_get_cqe(&cq->wq);
index 80d2121643ee6f8458b8c96cb20bb5db21e36ec6..fee43e40fa16a105de58981a40be26b320332090 100644 (file)
@@ -403,7 +403,7 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)
 
        sq = container_of(cq, struct mlx5e_txqsq, cq);
 
-       if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
+       if (unlikely(!MLX5E_TEST_BIT(sq->state, MLX5E_SQ_STATE_ENABLED)))
                return false;
 
        cqe = mlx5_cqwq_get_cqe(&cq->wq);
index 92db28a9ed43a89edcaf92c8d43db4d71ad68976..7311b937e43452c27039533fe7ec53a381d3bcc0 100644 (file)
@@ -69,7 +69,7 @@ static void mlx5e_poll_ico_cq(struct mlx5e_cq *cq)
        struct mlx5_cqe64 *cqe;
        u16 sqcc;
 
-       if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
+       if (unlikely(!MLX5E_TEST_BIT(sq->state, MLX5E_SQ_STATE_ENABLED)))
                return;
 
        cqe = mlx5_cqwq_get_cqe(&cq->wq);
@@ -129,7 +129,7 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
        for (i = 0; i < c->num_tc; i++)
                mlx5e_cq_arm(&c->sq[i].cq);
 
-       if (test_bit(MLX5E_RQ_STATE_AM, &c->rq.state))
+       if (MLX5E_TEST_BIT(c->rq.state, MLX5E_RQ_STATE_AM))
                mlx5e_rx_am(&c->rq);
 
        mlx5e_cq_arm(&c->rq.cq);