Author: hselasky
Date: Fri Sep 16 11:47:16 2016
New Revision: 305873
URL: https://svnweb.freebsd.org/changeset/base/305873

Log:
  mlx5en: Factor out common sendqueue code for use with rate limiting SQs.
  
  Try to reuse code to setup sendqueues when possible by making some static
  functions global. Further split the mlx5e_close_sq_wait() function to
  separate out reusable parts.
  
  Sponsored by: Mellanox Technologies
  MFC after:    1 week

Modified:
  head/sys/dev/mlx5/mlx5_en/en.h
  head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c

Modified: head/sys/dev/mlx5/mlx5_en/en.h
==============================================================================
--- head/sys/dev/mlx5/mlx5_en/en.h      Fri Sep 16 11:45:35 2016        
(r305872)
+++ head/sys/dev/mlx5/mlx5_en/en.h      Fri Sep 16 11:47:16 2016        
(r305873)
@@ -812,5 +812,11 @@ int        mlx5e_refresh_channel_params(struct 
 int    mlx5e_open_cq(struct mlx5e_priv *, struct mlx5e_cq_param *,
     struct mlx5e_cq *, mlx5e_cq_comp_t *, int eq_ix);
 void   mlx5e_close_cq(struct mlx5e_cq *);
+void   mlx5e_free_sq_db(struct mlx5e_sq *);
+int    mlx5e_alloc_sq_db(struct mlx5e_sq *);
+int    mlx5e_enable_sq(struct mlx5e_sq *, struct mlx5e_sq_param *, int 
tis_num);
+int    mlx5e_modify_sq(struct mlx5e_sq *, int curr_state, int next_state);
+void   mlx5e_disable_sq(struct mlx5e_sq *);
+void   mlx5e_drain_sq(struct mlx5e_sq *);
 
 #endif                                 /* _MLX5_EN_H_ */

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c    Fri Sep 16 11:45:35 2016        
(r305872)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c    Fri Sep 16 11:47:16 2016        
(r305873)
@@ -873,7 +873,7 @@ mlx5e_close_rq_wait(struct mlx5e_rq *rq)
        mlx5e_destroy_rq(rq);
 }
 
-static void
+void
 mlx5e_free_sq_db(struct mlx5e_sq *sq)
 {
        int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
@@ -884,7 +884,7 @@ mlx5e_free_sq_db(struct mlx5e_sq *sq)
        free(sq->mbuf, M_MLX5EN);
 }
 
-static int
+int
 mlx5e_alloc_sq_db(struct mlx5e_sq *sq)
 {
        int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
@@ -1033,8 +1033,9 @@ mlx5e_destroy_sq(struct mlx5e_sq *sq)
        buf_ring_free(sq->br, M_MLX5EN);
 }
 
-static int
-mlx5e_enable_sq(struct mlx5e_sq *sq, struct mlx5e_sq_param *param)
+int
+mlx5e_enable_sq(struct mlx5e_sq *sq, struct mlx5e_sq_param *param,
+    int tis_num)
 {
        void *in;
        void *sqc;
@@ -1053,7 +1054,7 @@ mlx5e_enable_sq(struct mlx5e_sq *sq, str
 
        memcpy(sqc, param->sqc, sizeof(param->sqc));
 
-       MLX5_SET(sqc, sqc, tis_num_0, sq->priv->tisn[sq->tc]);
+       MLX5_SET(sqc, sqc, tis_num_0, tis_num);
        MLX5_SET(sqc, sqc, cqn, sq->cq.mcq.cqn);
        MLX5_SET(sqc, sqc, state, MLX5_SQC_STATE_RST);
        MLX5_SET(sqc, sqc, tis_lst_sz, 1);
@@ -1075,7 +1076,7 @@ mlx5e_enable_sq(struct mlx5e_sq *sq, str
        return (err);
 }
 
-static int
+int
 mlx5e_modify_sq(struct mlx5e_sq *sq, int curr_state, int next_state)
 {
        void *in;
@@ -1101,7 +1102,7 @@ mlx5e_modify_sq(struct mlx5e_sq *sq, int
        return (err);
 }
 
-static void
+void
 mlx5e_disable_sq(struct mlx5e_sq *sq)
 {
 
@@ -1120,7 +1121,7 @@ mlx5e_open_sq(struct mlx5e_channel *c,
        if (err)
                return (err);
 
-       err = mlx5e_enable_sq(sq, param);
+       err = mlx5e_enable_sq(sq, param, c->priv->tisn[tc]);
        if (err)
                goto err_destroy_sq;
 
@@ -1196,8 +1197,8 @@ mlx5e_sq_cev_timeout(void *arg)
        callout_reset_curcpu(&sq->cev_callout, hz, mlx5e_sq_cev_timeout, sq);
 }
 
-static void
-mlx5e_close_sq_wait(struct mlx5e_sq *sq)
+void
+mlx5e_drain_sq(struct mlx5e_sq *sq)
 {
 
        mtx_lock(&sq->lock);
@@ -1224,7 +1225,13 @@ mlx5e_close_sq_wait(struct mlx5e_sq *sq)
                mtx_lock(&sq->lock);
        }
        mtx_unlock(&sq->lock);
+}
+
+static void
+mlx5e_close_sq_wait(struct mlx5e_sq *sq)
+{
 
+       mlx5e_drain_sq(sq);
        mlx5e_disable_sq(sq);
        mlx5e_destroy_sq(sq);
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to