\hypertarget{mlx5__en__dim_8c_source}{}\doxysection{mlx5\+\_\+en\+\_\+dim.\+c}
\label{mlx5__en__dim_8c_source}\index{dev/mlx5/mlx5\_en/mlx5\_en\_dim.c@{dev/mlx5/mlx5\_en/mlx5\_en\_dim.c}}
\mbox{\hyperlink{mlx5__en__dim_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00002}00002 \textcolor{comment}{ * Copyright (c) 2018 Mellanox Technologies. All rights reserved.}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00004}00004 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00005}00005 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00006}00006 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00007}00007 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00008}00008 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00009}00009 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00010}00010 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00011}00011 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00012}00012 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00013}00013 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00014}00014 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00015}00015 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00016}00016 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00017}00017 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00018}00018 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00019}00019 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00020}00020 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00021}00021 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00022}00022 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00023}00023 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00024}00024 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00025}00025 \textcolor{comment}{ * \$FreeBSD\$}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00026}00026 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00027}00027 }
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00028}00028 \textcolor{preprocessor}{\#include "{}opt\_rss.h"{}}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00029}00029 \textcolor{preprocessor}{\#include "{}opt\_ratelimit.h"{}}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00030}00030 }
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00031}00031 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{en_8h}{dev/mlx5/mlx5\_en/en.h}}>}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00032}00032 }
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00033}00033 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00034}\mbox{\hyperlink{en_8h_a95998bb92abba52555765d9966ac4d9b}{00034}} \mbox{\hyperlink{mlx5__en__dim_8c_ac1337157140f581f48ca4fe26c0dba99}{mlx5e\_dim\_build\_cq\_param}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structmlx5e__priv}{mlx5e\_priv}} *\mbox{\hyperlink{en_8h_a5fb0e4bc38f8b60aad81d13acf50020f}{priv}},}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00035}00035     \textcolor{keyword}{struct} \mbox{\hyperlink{structmlx5e__cq__param}{mlx5e\_cq\_param}} *param)}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00036}00036 \{}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00037}00037         \textcolor{keyword}{struct }net\_dim\_cq\_moder prof;}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00038}00038         \textcolor{keywordtype}{void} *cqc = param-\/>\mbox{\hyperlink{structmlx5e__cq__param_a782cd16b0ff40eba8cfc7ec417b2798f}{cqc}};}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00039}00039 }
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00040}00040         \textcolor{keywordflow}{if} (\mbox{\hyperlink{en_8h_a5fb0e4bc38f8b60aad81d13acf50020f}{priv}}-\/>\mbox{\hyperlink{structmlx5e__priv_a082db7e920f50827afe0cf93857b5043}{params}}.\mbox{\hyperlink{structmlx5e__params_af020d09ecf766e907d6d3e122d7ba865}{rx\_cq\_moderation\_mode}} < 2)}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00041}00041                 \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00042}00042 }
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00043}00043         \textcolor{keywordflow}{switch} (\mbox{\hyperlink{device_8h_a12a03f8a456490fce8c791c7f2922f97}{MLX5\_GET}}(cqc, cqc, cq\_period\_mode)) \{}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00044}00044         \textcolor{keywordflow}{case} \mbox{\hyperlink{mlx5__ifc_8h_a191c33aa19f004f13bed2b7be33756caa6c300faab962a9707d928be6e5feadb3}{MLX5\_CQ\_PERIOD\_MODE\_START\_FROM\_CQE}}:}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00045}00045                 prof = net\_dim\_profile[NET\_DIM\_CQ\_PERIOD\_MODE\_START\_FROM\_CQE]}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00046}00046                     [NET\_DIM\_DEF\_PROFILE\_CQE];}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00047}00047                 \mbox{\hyperlink{device_8h_a78623a3e69c7911bd715d06c32daa626}{MLX5\_SET}}(cqc, cqc, cq\_period, prof.usec);}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00048}00048                 \mbox{\hyperlink{device_8h_a78623a3e69c7911bd715d06c32daa626}{MLX5\_SET}}(cqc, cqc, cq\_max\_count, prof.pkts);}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00049}00049                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00050}00050 }
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00051}00051         \textcolor{keywordflow}{case} \mbox{\hyperlink{mlx5__ifc_8h_a191c33aa19f004f13bed2b7be33756caa8839b85465dabdf508d45435bead71d7}{MLX5\_CQ\_PERIOD\_MODE\_START\_FROM\_EQE}}:}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00052}00052                 prof = net\_dim\_profile[NET\_DIM\_CQ\_PERIOD\_MODE\_START\_FROM\_EQE]}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00053}00053                     [NET\_DIM\_DEF\_PROFILE\_EQE];}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00054}00054                 \mbox{\hyperlink{device_8h_a78623a3e69c7911bd715d06c32daa626}{MLX5\_SET}}(cqc, cqc, cq\_period, prof.usec);}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00055}00055                 \mbox{\hyperlink{device_8h_a78623a3e69c7911bd715d06c32daa626}{MLX5\_SET}}(cqc, cqc, cq\_max\_count, prof.pkts);}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00056}00056                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00057}00057         \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00058}00058                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00059}00059         \}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00060}00060 \}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00061}00061 }
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00062}00062 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00063}\mbox{\hyperlink{en_8h_a2cde1fcc1dd1e1c12618ed59189e078e}{00063}} \mbox{\hyperlink{mlx5__en__dim_8c_a5140071a3e1b0d58fdeb5f12d2197ba1}{mlx5e\_dim\_work}}(\textcolor{keyword}{struct} work\_struct *\mbox{\hyperlink{en__hw__tls_8h_a623997e11b94d7c467ce26627cc488a2}{work}})}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00064}00064 \{}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00065}00065         \textcolor{keyword}{struct }net\_dim *\mbox{\hyperlink{en_8h_a459ea3a5040a40143eb8403099f6c459}{dim}} = container\_of(\mbox{\hyperlink{en__hw__tls_8h_a623997e11b94d7c467ce26627cc488a2}{work}}, \textcolor{keyword}{struct} net\_dim, \mbox{\hyperlink{en__hw__tls_8h_a623997e11b94d7c467ce26627cc488a2}{work}});}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00066}00066         \textcolor{keyword}{struct }\mbox{\hyperlink{structmlx5e__rq}{mlx5e\_rq}} *\mbox{\hyperlink{en_8h_a34505eb7805ba3ccf9969192542b52ad}{rq}} = container\_of(\mbox{\hyperlink{en_8h_a459ea3a5040a40143eb8403099f6c459}{dim}}, \textcolor{keyword}{struct} \mbox{\hyperlink{structmlx5e__rq}{mlx5e\_rq}}, \mbox{\hyperlink{en_8h_a459ea3a5040a40143eb8403099f6c459}{dim}});}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00067}00067         \textcolor{keyword}{struct }\mbox{\hyperlink{structmlx5e__channel}{mlx5e\_channel}} *c = container\_of(\mbox{\hyperlink{en_8h_a34505eb7805ba3ccf9969192542b52ad}{rq}}, \textcolor{keyword}{struct} \mbox{\hyperlink{structmlx5e__channel}{mlx5e\_channel}}, \mbox{\hyperlink{en_8h_a34505eb7805ba3ccf9969192542b52ad}{rq}});}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00068}00068         \textcolor{keyword}{struct }net\_dim\_cq\_moder cur\_profile;}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00069}00069         u8 profile\_ix;}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00070}00070         u8 mode;}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00071}00071 }
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00072}00072         \textcolor{comment}{/* copy current auto moderation settings and set new state */}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00073}00073         mtx\_lock(\&\mbox{\hyperlink{en_8h_a34505eb7805ba3ccf9969192542b52ad}{rq}}-\/>\mbox{\hyperlink{structmlx5e__rq_a3f119df0480e3059832580c93b09c064}{mtx}});}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00074}00074         profile\_ix = \mbox{\hyperlink{en_8h_a459ea3a5040a40143eb8403099f6c459}{dim}}-\/>profile\_ix;}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00075}00075         mode = \mbox{\hyperlink{en_8h_a459ea3a5040a40143eb8403099f6c459}{dim}}-\/>mode;}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00076}00076         \mbox{\hyperlink{en_8h_a459ea3a5040a40143eb8403099f6c459}{dim}}-\/>state = NET\_DIM\_START\_MEASURE;}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00077}00077         mtx\_unlock(\&\mbox{\hyperlink{en_8h_a34505eb7805ba3ccf9969192542b52ad}{rq}}-\/>\mbox{\hyperlink{structmlx5e__rq_a3f119df0480e3059832580c93b09c064}{mtx}});}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00078}00078 }
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00079}00079         \textcolor{comment}{/* check for invalid mode */}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00080}00080         \textcolor{keywordflow}{if} (mode == 255)}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00081}00081                 \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00082}00082 }
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00083}00083         \textcolor{comment}{/* get current profile */}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00084}00084         cur\_profile = net\_dim\_profile[mode][profile\_ix];}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00085}00085 }
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00086}00086         \textcolor{comment}{/* apply LRO restrictions */}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00087}00087         \textcolor{keywordflow}{if} (c-\/>\mbox{\hyperlink{structmlx5e__channel_a876e7f03c2ea4d219f1a6bfa1d8463ab}{priv}}-\/>\mbox{\hyperlink{structmlx5e__priv_a082db7e920f50827afe0cf93857b5043}{params}}.\mbox{\hyperlink{structmlx5e__params_a38dfd7126e601a9dba0ec254cde85133}{hw\_lro\_en}} \&\&}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00088}00088             cur\_profile.pkts > \mbox{\hyperlink{en_8h_a8e440ad1a5207b51f4cf7355fc2ef44b}{MLX5E\_DIM\_MAX\_RX\_CQ\_MODERATION\_PKTS\_WITH\_LRO}}) \{}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00089}00089                 cur\_profile.pkts = \mbox{\hyperlink{en_8h_a8e440ad1a5207b51f4cf7355fc2ef44b}{MLX5E\_DIM\_MAX\_RX\_CQ\_MODERATION\_PKTS\_WITH\_LRO}};}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00090}00090         \}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00091}00091 }
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00092}00092         \textcolor{comment}{/* modify CQ */}}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00093}00093         \mbox{\hyperlink{cq_8h_af35b8c739c52933c447ea25a9e0532d6}{mlx5\_core\_modify\_cq\_moderation}}(c-\/>\mbox{\hyperlink{structmlx5e__channel_a876e7f03c2ea4d219f1a6bfa1d8463ab}{priv}}-\/>\mbox{\hyperlink{structmlx5e__priv_a2223d57c4964aa044a50089734600ab8}{mdev}}, \&\mbox{\hyperlink{en_8h_a34505eb7805ba3ccf9969192542b52ad}{rq}}-\/>\mbox{\hyperlink{structmlx5e__rq_a7a4768d6d167831e23f888181960237f}{cq}}.\mbox{\hyperlink{structmlx5e__cq_ad9262877d1d03c6f244bdd35128e89ba}{mcq}},}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00094}00094             cur\_profile.usec, cur\_profile.pkts);}
\DoxyCodeLine{\Hypertarget{mlx5__en__dim_8c_source_l00095}00095 \}}

\end{DoxyCode}
