From: Fan Zhang <roy.fan.zhang@intel.com>
To: dev@dpdk.org
Cc: akhil.goyal@nxp.com, pablo.de.lara.guarch@intel.com,
fiona.trahe@intel.com
Subject: [dpdk-dev] [PATCH v4 09/12] cryptodev: update symmetric session structure
Date: Wed, 9 Jan 2019 22:56:06 +0000 [thread overview]
Message-ID: <20190109225609.20590-10-roy.fan.zhang@intel.com> (raw)
In-Reply-To: <20190109225609.20590-1-roy.fan.zhang@intel.com>
This patch updates the rte_cryptodev_sym_session structure for
cryptodev library. The updates include a changed session private
data array and an added nb_drivers field. They are used to
calculate the correct session header size and ensure safe access
of the session private data.
Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
---
doc/guides/prog_guide/img/cryptodev_sym_sess.svg | 701 ++++++++++++-----------
doc/guides/rel_notes/release_19_02.rst | 7 +-
lib/librte_cryptodev/rte_cryptodev.c | 100 +++-
lib/librte_cryptodev/rte_cryptodev.h | 8 +-
lib/librte_cryptodev/rte_cryptodev_pmd.h | 13 +-
5 files changed, 444 insertions(+), 385 deletions(-)
diff --git a/doc/guides/prog_guide/img/cryptodev_sym_sess.svg b/doc/guides/prog_guide/img/cryptodev_sym_sess.svg
index a807cebac..5c843f736 100644
--- a/doc/guides/prog_guide/img/cryptodev_sym_sess.svg
+++ b/doc/guides/prog_guide/img/cryptodev_sym_sess.svg
@@ -19,33 +19,31 @@
id="svg70"
sodipodi:docname="cryptodev_sym_sess.svg"
style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-rule:evenodd;stroke-linecap:square;stroke-miterlimit:3"
- inkscape:version="0.92.1 r15371"><metadata
- id="metadata74"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1"
- objecttolerance="10"
- gridtolerance="10"
- guidetolerance="10"
- inkscape:pageopacity="0"
- inkscape:pageshadow="2"
- inkscape:window-width="1920"
- inkscape:window-height="1051"
- id="namedview72"
- showgrid="false"
- inkscape:zoom="1.7495789"
- inkscape:cx="208.74719"
- inkscape:cy="216.52777"
- inkscape:window-x="-9"
- inkscape:window-y="-9"
- inkscape:window-maximized="0"
- inkscape:current-layer="g68-0" />
- <style
- type="text/css"
- id="style2">
- <![CDATA[
+ inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"><metadata
+ id="metadata74"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1920"
+ inkscape:window-height="956"
+ id="namedview72"
+ showgrid="false"
+ inkscape:zoom="1.7495789"
+ inkscape:cx="208.74719"
+ inkscape:cy="216.52777"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="shape18-1-4" /><style
+ type="text/css"
+ id="style2"><![CDATA[
.st1 {fill:url(#grad0-4);stroke:#386288;stroke-width:0.75}
.st2 {fill:#386288;font-family:Calibri;font-size:0.833336em}
.st3 {visibility:visible}
@@ -56,337 +54,340 @@
.st8 {font-size:0.799995em}
.st9 {font-size:0.799995em;font-weight:bold}
.st10 {fill:none;fill-rule:evenodd;font-size:12px;overflow:visible;stroke-linecap:square;stroke-miterlimit:3}
- ]]>
- </style>
-
- <defs
- id="Patterns_And_Gradients"><marker
- inkscape:isstock="true"
- style="overflow:visible"
- id="marker5421"
- refX="0"
- refY="0"
- orient="auto"
- inkscape:stockid="Arrow2Lend"><path
- transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
- d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
- style="fill:#41719c;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
- id="path5419"
- inkscape:connector-curvature="0" /></marker><marker
- inkscape:stockid="Arrow2Lend"
- orient="auto"
- refY="0"
- refX="0"
- id="Arrow2Lend"
- style="overflow:visible"
- inkscape:isstock="true"><path
- id="path5004"
- style="fill:#41719c;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
- d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
- transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
- inkscape:connector-curvature="0" /></marker><marker
- inkscape:stockid="Arrow1Lend"
- orient="auto"
- refY="0"
- refX="0"
- id="Arrow1Lend"
- style="overflow:visible"
- inkscape:isstock="true"><path
- id="path4986"
- d="M 0,0 5,-5 -12.5,0 5,5 Z"
- style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
- transform="matrix(-0.8,0,0,-0.8,-10,0)"
- inkscape:connector-curvature="0" /></marker>
- <linearGradient
- id="grad0-4"
- x1="0"
- y1="0"
- x2="1"
- y2="0"
- gradientTransform="rotate(60,0.5,0.5)">
- <stop
- offset="0"
- stop-color="#e8ebef"
- stop-opacity="1"
- id="stop4" />
- <stop
- offset="0.24"
- stop-color="#f4f5f7"
- stop-opacity="1"
- id="stop6" />
- <stop
- offset="0.54"
- stop-color="#feffff"
- stop-opacity="1"
- id="stop8" />
- </linearGradient>
- <filter
- id="filter_2-4"><feGaussianBlur
- stdDeviation="2"
- id="feGaussianBlur12-0" /></filter><linearGradient
- inkscape:collect="always"
- xlink:href="#grad0-4"
- id="linearGradient189"
- gradientTransform="scale(0.8787489,1.1379815)"
- x1="-0.42674366"
- y1="0.98859203"
- x2="176.71146"
- y2="0.98859203"
- gradientUnits="userSpaceOnUse" /><filter
- id="filter_2-5"><feGaussianBlur
- stdDeviation="2"
- id="feGaussianBlur12-8" /></filter><filter
- id="filter_2-3"><feGaussianBlur
- stdDeviation="2"
- id="feGaussianBlur12-2" /></filter><linearGradient
- inkscape:collect="always"
- xlink:href="#grad0-4"
- id="linearGradient189-7"
- gradientTransform="scale(0.8787489,1.1379815)"
- x1="-0.42674366"
- y1="0.98859203"
- x2="176.71146"
- y2="0.98859203"
- gradientUnits="userSpaceOnUse" /><linearGradient
- inkscape:collect="always"
- xlink:href="#grad0-4"
- id="linearGradient500"
- gradientTransform="matrix(0.8787489,0,0,1.1379815,12.431599,21.739241)"
- x1="-0.42674366"
- y1="0.98859203"
- x2="176.71146"
- y2="0.98859203"
- gradientUnits="userSpaceOnUse" /></defs>
- <defs
- id="Filters">
- <filter
- id="filter_2">
- <feGaussianBlur
- stdDeviation="2"
- id="feGaussianBlur12" />
- </filter>
- </defs>
- <g
- id="g68"
- transform="matrix(1,0,0,0.41409874,-12.807629,-5.4621159)">
- <title
- id="title16">Page-1</title>
- <g
- id="shape18-1"
- transform="translate(0.749889,-0.75)">
- <title
- id="title18">Rounded Rectangle.12</title>
- <desc
- id="desc20">Crypto Symmetric Session</desc>
- <path
- d="M 19.211599,224.06924 H 160.5716 a 6.77735,6.77735 0 0 0 6.77,-6.77 V 30.019241 a 6.77735,6.77735 0 0 0 -6.77,-6.78 H 19.211599 a 6.77735,6.77735 0 0 0 -6.78,6.78 V 217.29924 a 6.77735,6.77735 0 0 0 6.78,6.77 z"
- class="st1"
- id="path22"
- style="fill:url(#linearGradient500);stroke:#386288;stroke-width:0.75"
- inkscape:connector-curvature="0" />
- <text
- x="63.123039"
- y="28.531481"
- class="st2"
- id="text24"
- style="font-size:16.97244835px;font-family:Calibri;fill:#386288;stroke-width:1.69723928"
- transform="scale(0.58919214,1.6972392)">Crypto Symmetric Session</text>
-
- </g>
- <g
- id="shape19-6"
- transform="translate(10.6711,-9.82087)">
- <title
- id="title27">Rounded Rectangle.13</title>
- <desc
- id="desc29">Private Session Data</desc>
- </g>
- <g
- id="shape20-12"
- transform="matrix(1,0,0,2.5278193,23.531375,-309.78186)">
- <title
- id="title39">Rounded Rectangle.15</title>
- <desc
- id="desc41">void *sess_private_data[]</desc>
- <path
- d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -36.37 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,160.06 v 36.37 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
- class="st7"
- id="path43"
- inkscape:connector-curvature="0"
- style="fill:#ffffff;stroke:#41719c;stroke-width:0.75" />
- <text
- x="14.072042"
- y="159.1931"
- class="st6"
- id="text65"
- style="font-size:11.41061592px;font-family:Calibri;fill:#41719c;stroke-width:1.14105785"
- transform="scale(0.92359087,1.0827305)">void *sess_private_data[] <tspan
- x="-3.5230706"
- class="st9"
- id="tspan47"
- style="font-weight:bold;font-size:9.12843513px;stroke-width:1.14105785" /></text>
-
- <rect
- style="fill:none;fill-opacity:1;stroke:#41719c;stroke-width:0.73305672;stroke-opacity:1"
- id="rect4604"
- width="15.968175"
- height="14.230948"
- x="13.494645"
- y="181.68814" /><rect
- style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
- id="rect4604-7"
- width="15.968174"
- height="14.230948"
- x="29.46282"
- y="181.68814" /><rect
- style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
- id="rect4604-7-6"
- width="15.968174"
- height="14.230948"
- x="45.430992"
- y="181.68814" /><rect
- style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
- id="rect4604-7-6-9"
- width="15.968174"
- height="14.230948"
- x="61.399166"
- y="181.68814" /><rect
- style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
- id="rect4604-7-6-9-8"
- width="15.968174"
- height="14.230948"
- x="77.36734"
- y="181.68814" /><rect
- style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
- id="rect4604-7-6-9-8-9"
- width="15.968174"
- height="14.230948"
- x="93.33551"
- y="181.68814" /><rect
- style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.73305672;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1"
- id="rect4604-7-6-9-8-9-6"
- width="15.968174"
- height="14.230948"
- x="109.30369"
- y="181.68814" /><path
- style="fill:none;fill-opacity:1;stroke:#41719c;stroke-width:0.72427988px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
- d="m 117.64885,196.01764 0.22164,18.77485 44.6966,-0.0725 -0.22163,-20.00716 16.84434,0.43494"
- id="path5030"
- inkscape:connector-curvature="0" /></g>
- </g>
-<g
- transform="translate(190.70887,-0.53319281)"
- id="g68-0"><title
- id="title16-2">Page-1</title><g
- id="shape18-1-4"
- transform="matrix(1,0,0,0.57815109,0.749889,-0.11722686)"><title
- id="title18-4">Rounded Rectangle.12</title><desc
- id="desc20-6">Crypto Symmetric Session</desc><path
- inkscape:connector-curvature="0"
- d="m 6.78,202.33 h 141.36 a 6.77735,6.77735 -180 0 0 6.77,-6.77 V 8.28 A 6.77735,6.77735 -180 0 0 148.14,1.5 H 6.78 A 6.77735,6.77735 -180 0 0 0,8.28 v 187.28 a 6.77735,6.77735 -180 0 0 6.78,6.77 z"
- class="st1"
- id="path22-0"
- style="fill:url(#linearGradient189);stroke:#386288;stroke-width:0.75" /><text
- x="26.317923"
- y="17.335487"
- class="st2"
- id="text24-5"
- style="font-size:14.02988338px;font-family:Calibri;fill:#386288;stroke-width:1.40298378"
- transform="scale(0.71276665,1.4029837)">Crypto Driver Private Session</text>
-
-</g><g
- id="shape19-6-5"
- transform="matrix(1.022976,0,0,0.71529071,9.1114734,-39.403506)"><title
- id="title27-2">Rounded Rectangle.13</title><desc
- id="desc29-0">Private Session Data</desc><g
- id="shadow19-7-1"
- transform="translate(0.345598,1.97279)"
- class="st3"
- style="visibility:visible"><path
+ ]]></style><defs
+ id="Patterns_And_Gradients"><marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker5421"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="Arrow2Lend"><path
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ style="fill:#41719c;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+ id="path5419"
+ inkscape:connector-curvature="0" /></marker><marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lend"
+ style="overflow:visible"
+ inkscape:isstock="true"><path
+ id="path5004"
+ style="fill:#41719c;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+ inkscape:connector-curvature="0" /></marker><marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lend"
+ style="overflow:visible"
+ inkscape:isstock="true"><path
+ id="path4986"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ inkscape:connector-curvature="0" /></marker><linearGradient
+ id="grad0-4"
+ x1="0"
+ y1="0"
+ x2="1"
+ y2="0"
+ gradientTransform="rotate(60,0.5,0.5)"><stop
+ offset="0"
+ stop-color="#e8ebef"
+ stop-opacity="1"
+ id="stop4" /><stop
+ offset="0.24"
+ stop-color="#f4f5f7"
+ stop-opacity="1"
+ id="stop6" /><stop
+ offset="0.54"
+ stop-color="#feffff"
+ stop-opacity="1"
+ id="stop8" /></linearGradient><filter
+ id="filter_2-4"><feGaussianBlur
+ stdDeviation="2"
+ id="feGaussianBlur12-0" /></filter><linearGradient
+ inkscape:collect="always"
+ xlink:href="#grad0-4"
+ id="linearGradient189"
+ gradientTransform="scale(0.8787489,1.1379815)"
+ x1="-0.42674366"
+ y1="0.98859203"
+ x2="176.71146"
+ y2="0.98859203"
+ gradientUnits="userSpaceOnUse" /><filter
+ id="filter_2-5"><feGaussianBlur
+ stdDeviation="2"
+ id="feGaussianBlur12-8" /></filter><filter
+ id="filter_2-3"><feGaussianBlur
+ stdDeviation="2"
+ id="feGaussianBlur12-2" /></filter><linearGradient
+ inkscape:collect="always"
+ xlink:href="#grad0-4"
+ id="linearGradient189-7"
+ gradientTransform="scale(0.8787489,1.1379815)"
+ x1="-0.42674366"
+ y1="0.98859203"
+ x2="176.71146"
+ y2="0.98859203"
+ gradientUnits="userSpaceOnUse" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#grad0-4"
+ id="linearGradient500"
+ gradientTransform="matrix(0.87785006,0,0,2.0116303,15.940232,20.619826)"
+ x1="-0.42674366"
+ y1="0.98859203"
+ x2="176.71146"
+ y2="0.98859203"
+ gradientUnits="userSpaceOnUse" /></defs><defs
+ id="Filters"><filter
+ id="filter_2"><feGaussianBlur
+ stdDeviation="2"
+ id="feGaussianBlur12" /></filter></defs><g
+ transform="matrix(1,0,0,0.41409874,-12.05774,-5.77269)"
+ id="shape18-1"><title
+ id="title18">Rounded Rectangle.12</title><desc
+ id="desc20">Crypto Symmetric Session</desc><path
+ inkscape:connector-curvature="0"
+ style="fill:url(#linearGradient500);stroke:#386288;stroke-width:0.99665654"
+ id="path22"
+ class="st1"
+ d="M 22.713297,378.28219 H 163.92871 a 6.7704177,11.980443 0 0 0 6.76307,-11.96745 V 35.256532 A 6.7704177,11.980443 0 0 0 163.92871,23.271405 H 22.713297 A 6.7704177,11.980443 0 0 0 15.940232,35.256532 V 366.31474 a 6.7704177,11.980443 0 0 0 6.773065,11.96745 z" /></g><g
+ transform="matrix(1,0,0,0.41409874,-2.136529,-9.5289258)"
+ id="shape19-6"><title
+ id="title27">Rounded Rectangle.13</title><desc
+ id="desc29">Private Session Data</desc></g><g
+ id="g4079"
+ transform="matrix(0.9997031,0,0,1.070998,206.15511,-5.6465883)"><path
+ style="fill:#ffffff;stroke:#41719c;stroke-width:1.15444767"
+ inkscape:connector-curvature="0"
+ id="path43"
+ class="st7"
+ d="m -189.55935,139.62776 h 123.25 a 5.90925,14.000977 0 0 0 5.91,-13.97905 V 39.476089 a 5.90925,14.000977 0 0 0 -5.91,-14.002757 h -123.25 a 5.90925,14.000977 0 0 0 -5.91,14.002757 v 86.172621 a 5.90925,14.000977 0 0 0 5.91,13.97905 z" /><rect
+ y="118.60072"
+ x="-181.11736"
+ height="14.896484"
+ width="15.968175"
+ id="rect4604"
+ style="fill:none;fill-opacity:1;stroke:#41719c;stroke-width:0.75000221;stroke-opacity:1" /><rect
+ y="118.60072"
+ x="-165.14919"
+ height="14.896484"
+ width="15.968174"
+ id="rect4604-7"
+ style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.75000221;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1" /><rect
+ y="118.60072"
+ x="-149.181"
+ height="14.896484"
+ width="15.968174"
+ id="rect4604-7-6"
+ style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.75000221;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1" /><rect
+ y="118.60072"
+ x="-133.21283"
+ height="14.896484"
+ width="15.968174"
+ id="rect4604-7-6-9"
+ style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.75000221;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1" /><rect
+ y="118.60072"
+ x="-117.24466"
+ height="14.896484"
+ width="15.968174"
+ id="rect4604-7-6-9-8"
+ style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.75000221;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1" /><rect
+ y="118.60072"
+ x="-101.27649"
+ height="14.896484"
+ width="15.968174"
+ id="rect4604-7-6-9-8-9"
+ style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.75000221;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1" /><rect
+ y="118.60072"
+ x="-85.308311"
+ height="14.896484"
+ width="15.968174"
+ id="rect4604-7-6-9-8-9-6"
+ style="font-size:12px;overflow:visible;color-interpolation-filters:sRGB;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#41719c;stroke-width:0.75000221;stroke-linecap:square;stroke-miterlimit:3;stroke-opacity:1" /><text
+ transform="scale(0.48757738,2.0509565)"
+ style="font-size:21.61449814px;font-family:Calibri;overflow:visible;color-interpolation-filters:sRGB;fill:#41719c;fill-rule:evenodd;stroke-width:2.16144276;stroke-linecap:square;stroke-miterlimit:3"
+ id="text65-3"
+ class="st6"
+ y="50.793892"
+ x="-374.07562" />
+<text
+ xml:space="preserve"
+ style="font-style:normal;font-weight:normal;font-size:28.99296951px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.72482425"
+ x="-172.30693"
+ y="83.585136"
+ id="text4129"
+ transform="scale(1.035044,0.96614251)"><tspan
+ sodipodi:role="line"
+ id="tspan4127"
+ x="-172.30693"
+ y="109.23712"
+ style="stroke-width:0.72482425"></tspan></text>
+<text
+ xml:space="preserve"
+ style="font-style:normal;font-weight:normal;font-size:28.99296951px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.72482425"
+ x="-174.79263"
+ y="75.713715"
+ id="text4139"
+ transform="scale(1.035044,0.96614251)"><tspan
+ sodipodi:role="line"
+ id="tspan4137"
+ x="-174.79263"
+ y="101.3657"
+ style="stroke-width:0.72482425"></tspan></text>
+</g><path
+ style="fill:none;fill-opacity:1;stroke:#41719c;stroke-width:0.86738265px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
+ d="m 128.80127,137.90141 -0.20704,20.06801 44.6966,-0.10399 0.20705,-93.424256 16.84434,0.62379"
+ id="path5030"
inkscape:connector-curvature="0"
- d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
- class="st4"
- id="path31-8"
- style="fill:#bdd0e9;fill-opacity:0.25;stroke:#bdd0e9;stroke-opacity:0.25;filter:url(#filter_2)" /></g><path
- inkscape:connector-curvature="0"
- d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
- class="st5"
- id="path34-8"
- style="fill:#a6b6cd;stroke:#41719c;stroke-width:0.75" /><text
- x="34.639763"
- y="119.96548"
- class="st6"
- id="text36-7"
- style="font-size:13.15105343px;font-family:Calibri;fill:#41719c;stroke-width:1.31510115"
- transform="scale(0.76039781,1.3151011)">Private Session Data</text>
-
+ sodipodi:nodetypes="ccccc" /><g
+ transform="matrix(1,0,0,0.57815109,191.45876,-0.65041967)"
+ id="shape18-1-4"><title
+ id="title18-4">Rounded Rectangle.12</title><desc
+ id="desc20-6">Crypto Symmetric Session</desc><path
+ style="fill:url(#linearGradient189);stroke:#386288;stroke-width:0.75"
+ id="path22-0"
+ class="st1"
+ d="m 6.78,202.33 h 141.36 a 6.77735,6.77735 -180 0 0 6.77,-6.77 V 8.28 A 6.77735,6.77735 -180 0 0 148.14,1.5 H 6.78 A 6.77735,6.77735 -180 0 0 0,8.28 v 187.28 a 6.77735,6.77735 -180 0 0 6.78,6.77 z"
+ inkscape:connector-curvature="0" /><text
+ transform="scale(0.71276665,1.4029837)"
+ style="font-size:14.02988338px;font-family:Calibri;fill:#386288;stroke-width:1.40298378"
+ id="text24-5"
+ class="st2"
+ y="17.335487"
+ x="26.317923">Crypto Driver Private Session</text>
+<text
+ transform="scale(0.71276665,1.4029837)"
+ style="font-size:14.02988338px;font-family:Calibri;overflow:visible;color-interpolation-filters:sRGB;fill:#386288;fill-rule:evenodd;stroke-width:1.40298378;stroke-linecap:square;stroke-miterlimit:3"
+ id="text24-5-3"
+ class="st2"
+ y="19.076277"
+ x="-240.04274">Crypto Symmetric Session</text>
+<text
+ transform="scale(0.71276665,1.4029837)"
+ style="font-size:14.02988338px;font-family:Calibri;overflow:visible;color-interpolation-filters:sRGB;fill:#386288;fill-rule:evenodd;stroke-width:1.40298378;stroke-linecap:square;stroke-miterlimit:3"
+ id="text24-5-5"
+ class="st2"
+ y="46.557648"
+ x="-241.24557">uint16_t nb_drivers;</text>
+<text
+ transform="scale(0.71276665,1.4029837)"
+ style="font-size:14.02988338px;font-family:Calibri;overflow:visible;color-interpolation-filters:sRGB;fill:#386288;fill-rule:evenodd;stroke-width:1.40298378;stroke-linecap:square;stroke-miterlimit:3"
+ id="text24-5-6"
+ class="st2"
+ y="98.349464"
+ x="-240.04272">struct {</text>
+<text
+ transform="scale(0.71276665,1.4029837)"
+ style="font-size:14.02988338px;font-family:Calibri;overflow:visible;color-interpolation-filters:sRGB;fill:#386288;fill-rule:evenodd;stroke-width:1.40298378;stroke-linecap:square;stroke-miterlimit:3"
+ id="text24-5-2"
+ class="st2"
+ y="115.26107"
+ x="-204.55865">void *data;</text>
+<text
+ transform="scale(0.71276665,1.4029837)"
+ style="font-size:14.02988338px;font-family:Calibri;overflow:visible;color-interpolation-filters:sRGB;fill:#386288;fill-rule:evenodd;stroke-width:1.40298378;stroke-linecap:square;stroke-miterlimit:3"
+ id="text24-5-9"
+ class="st2"
+ y="144.3279"
+ x="-240.04274">} session_data[];</text>
</g><g
- id="shape18-1-4-7"
- transform="matrix(1,0,0,0.57815109,0.90591369,163.94402)"><title
- id="title18-4-3">Rounded Rectangle.12</title><desc
- id="desc20-6-5">Crypto Symmetric Session</desc><path
- inkscape:connector-curvature="0"
- d="m 6.78,202.33 h 141.36 a 6.77735,6.77735 -180 0 0 6.77,-6.77 V 8.28 A 6.77735,6.77735 -180 0 0 148.14,1.5 H 6.78 A 6.77735,6.77735 -180 0 0 0,8.28 v 187.28 a 6.77735,6.77735 -180 0 0 6.78,6.77 z"
- class="st1"
- id="path22-0-8"
- style="fill:url(#linearGradient189-7);stroke:#386288;stroke-width:0.75" /><text
- x="26.317923"
- y="17.335487"
- class="st2"
- id="text24-5-1"
- style="font-size:14.02988338px;font-family:Calibri;fill:#386288;stroke-width:1.40298378"
- transform="scale(0.71276665,1.4029837)">Crypto Driver Private Session</text>
-
+ transform="matrix(1.022976,0,0,0.71529071,199.82034,-39.936699)"
+ id="shape19-6-5"><title
+ id="title27-2">Rounded Rectangle.13</title><desc
+ id="desc29-0">Private Session Data</desc><g
+ style="visibility:visible"
+ class="st3"
+ transform="translate(0.345598,1.97279)"
+ id="shadow19-7-1"><path
+ style="fill:#bdd0e9;fill-opacity:0.25;stroke:#bdd0e9;stroke-opacity:0.25;filter:url(#filter_2)"
+ id="path31-8"
+ class="st4"
+ d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+ inkscape:connector-curvature="0" /></g><path
+ style="fill:#a6b6cd;stroke:#41719c;stroke-width:0.75"
+ id="path34-8"
+ class="st5"
+ d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+ inkscape:connector-curvature="0" /><text
+ transform="scale(0.76039781,1.3151011)"
+ style="font-size:13.15105343px;font-family:Calibri;fill:#41719c;stroke-width:1.31510115"
+ id="text36-7"
+ class="st6"
+ y="119.96548"
+ x="34.639763">Private Session Data</text>
</g><g
- id="shape19-6-5-1"
- transform="matrix(1.022976,0,0,0.71529071,9.2675037,124.65774)"><title
- id="title27-2-4">Rounded Rectangle.13</title><desc
- id="desc29-0-9">Private Session Data</desc><g
- id="shadow19-7-1-8"
- transform="translate(0.345598,1.97279)"
- class="st3"
- style="visibility:visible"><path
- inkscape:connector-curvature="0"
- d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
- class="st4"
- id="path31-8-4"
- style="fill:#bdd0e9;fill-opacity:0.25;stroke:#bdd0e9;stroke-opacity:0.25;filter:url(#filter_2-3)" /></g><path
- inkscape:connector-curvature="0"
- d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
- class="st5"
- id="path34-8-3"
- style="fill:#a6b6cd;stroke:#41719c;stroke-width:0.75" /><text
- x="34.639763"
- y="119.96548"
- class="st6"
- id="text36-7-6"
- style="font-size:13.15105343px;font-family:Calibri;fill:#41719c;stroke-width:1.31510115"
- transform="scale(0.76039781,1.3151011)">Private Session Data</text>
-
+ transform="matrix(1,0,0,0.57815109,191.61478,163.41083)"
+ id="shape18-1-4-7"><title
+ id="title18-4-3">Rounded Rectangle.12</title><desc
+ id="desc20-6-5">Crypto Symmetric Session</desc><path
+ style="fill:url(#linearGradient189-7);stroke:#386288;stroke-width:0.75"
+ id="path22-0-8"
+ class="st1"
+ d="m 6.78,202.33 h 141.36 a 6.77735,6.77735 -180 0 0 6.77,-6.77 V 8.28 A 6.77735,6.77735 -180 0 0 148.14,1.5 H 6.78 A 6.77735,6.77735 -180 0 0 0,8.28 v 187.28 a 6.77735,6.77735 -180 0 0 6.78,6.77 z"
+ inkscape:connector-curvature="0" /><text
+ transform="scale(0.71276665,1.4029837)"
+ style="font-size:14.02988338px;font-family:Calibri;fill:#386288;stroke-width:1.40298378"
+ id="text24-5-1"
+ class="st2"
+ y="17.335487"
+ x="26.317923">Crypto Driver Private Session</text>
+</g><g
+ transform="matrix(1.022976,0,0,0.71529071,199.97637,124.12455)"
+ id="shape19-6-5-1"><title
+ id="title27-2-4">Rounded Rectangle.13</title><desc
+ id="desc29-0-9">Private Session Data</desc><g
+ style="visibility:visible"
+ class="st3"
+ transform="translate(0.345598,1.97279)"
+ id="shadow19-7-1-8"><path
+ style="fill:#bdd0e9;fill-opacity:0.25;stroke:#bdd0e9;stroke-opacity:0.25;filter:url(#filter_2-3)"
+ id="path31-8-4"
+ class="st4"
+ d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+ inkscape:connector-curvature="0" /></g><path
+ style="fill:#a6b6cd;stroke:#41719c;stroke-width:0.75"
+ id="path34-8-3"
+ class="st5"
+ d="m 5.91,202.33 h 123.25 a 5.90925,5.90925 -180 0 0 5.91,-5.9 v -92.78 a 5.90925,5.90925 -180 0 0 -5.91,-5.91 H 5.91 A 5.90925,5.90925 -180 0 0 0,103.65 v 92.78 a 5.90925,5.90925 -180 0 0 5.91,5.9 z"
+ inkscape:connector-curvature="0" /><text
+ transform="scale(0.76039781,1.3151011)"
+ style="font-size:13.15105343px;font-family:Calibri;fill:#41719c;stroke-width:1.31510115"
+ id="text36-7-6"
+ class="st6"
+ y="119.96548"
+ x="34.639763">Private Session Data</text>
</g><text
- xml:space="preserve"
+ id="text5070"
+ y="145.4136"
+ x="248.24945"
style="font-style:normal;font-weight:normal;font-size:30.00008774px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75000221"
- x="57.540585"
- y="145.94679"
- id="text5070"><tspan
- sodipodi:role="line"
+ xml:space="preserve"><tspan
+ style="stroke-width:0.75000221"
+ y="171.95665"
+ x="248.24945"
id="tspan5068"
- x="57.540585"
- y="173.31679"
- style="stroke-width:0.75000221"></tspan></text>
+ sodipodi:role="line" /></text>
<text
- xml:space="preserve"
+ id="text5074"
+ y="142.68553"
+ x="251.28064"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.00006485px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75000221"
- x="60.571766"
- y="143.21872"
- id="text5074"><tspan
- sodipodi:role="line"
+ xml:space="preserve"><tspan
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.00006485px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.75000221"
+ y="142.68553"
+ x="251.28064"
id="tspan5072"
- x="60.571766"
- y="143.21872"
- style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:22.00006485px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.75000221">...</tspan></text>
+ sodipodi:role="line">...</tspan></text>
<path
- style="fill:none;stroke:#41719c;stroke-width:0.74499911px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker5421)"
- d="M -158.57624,71.371238 -157.38,232.04055 -1.1215065,232.19212"
+ inkscape:connector-curvature="0"
id="path5076"
- inkscape:connector-curvature="0" /></g></svg>
+ d="m 32.13263,137.96494 1.19624,93.60569 156.25849,0.0883"
+ style="fill:none;stroke:#41719c;stroke-width:0.56864393px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker5421)" /></svg>
\ No newline at end of file
diff --git a/doc/guides/rel_notes/release_19_02.rst b/doc/guides/rel_notes/release_19_02.rst
index 445d6a809..740b24dd7 100644
--- a/doc/guides/rel_notes/release_19_02.rst
+++ b/doc/guides/rel_notes/release_19_02.rst
@@ -170,7 +170,8 @@ API Changes
* cryptodev: a new function ``rte_cryptodev_sym_session_pool_create()`` is
introduced. This function is used to create symmetric session mempool safely
and all crypto applications are required to use this function to create
- symmetric session mempool from now on.
+ symmetric session mempool from now on. Failed to do so will cause
+ ``rte_cryptodev_sym_session_create()`` function call return error.
* cryptodev: introduced a new function
``rte_cryptodev_sym_get_existing_header_session_size()``. The function is
@@ -202,6 +203,10 @@ ABI Changes
``rte_cryptodev_qp_conf`` has been added two parameters of symmetric session
mempool and symmetric session private data mempool.
+* cryptodev: as shown in the the 18.11 deprecation notice, the structure
+ ``rte_cryptodev_sym_session`` has been updated to contain more information
+ to ensure safely accessing the session and session private data.
+
Shared Library Versions
-----------------------
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index f4f1cf598..ea61f9269 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -978,6 +978,30 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
return -EINVAL;
}
+ if (qp_conf->mp_session) {
+ struct rte_cryptodev_sym_session_pool_private_data *pool_priv;
+ uint32_t obj_size = qp_conf->mp_session->elt_size;
+ uint32_t obj_priv_size = qp_conf->mp_session_private->elt_size;
+ struct rte_cryptodev_sym_session s = {0};
+
+ pool_priv = rte_mempool_get_priv(qp_conf->mp_session);
+ if (!pool_priv || qp_conf->mp_session->private_data_size <
+ sizeof(*pool_priv)) {
+ CDEV_LOG_ERR("Invalid mempool\n");
+ return -EINVAL;
+ }
+
+ s.nb_drivers = pool_priv->nb_drivers;
+
+ if ((rte_cryptodev_sym_get_existing_header_session_size(&s) >
+ obj_size) || (s.nb_drivers <= dev->driver_id) ||
+ rte_cryptodev_sym_get_private_session_size(dev_id) >
+ obj_priv_size) {
+ CDEV_LOG_ERR("Invalid mempool\n");
+ return -EINVAL;
+ }
+ }
+
if (dev->data->dev_started) {
CDEV_LOG_ERR(
"device %d must be stopped to allow configuration", dev_id);
@@ -1172,6 +1196,8 @@ rte_cryptodev_sym_session_init(uint8_t dev_id,
struct rte_mempool *mp)
{
struct rte_cryptodev *dev;
+ uint32_t sess_priv_sz = rte_cryptodev_sym_get_private_session_size(
+ dev_id);
uint8_t index;
int ret;
@@ -1180,11 +1206,16 @@ rte_cryptodev_sym_session_init(uint8_t dev_id,
if (sess == NULL || xforms == NULL || dev == NULL)
return -EINVAL;
+ if (mp->elt_size < sess_priv_sz)
+ return -EINVAL;
+
index = dev->driver_id;
+ if (index >= sess->nb_drivers)
+ return -EINVAL;
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->sym_session_configure, -ENOTSUP);
- if (sess->sess_private_data[index] == NULL) {
+ if (sess->sess_data[index].data == NULL) {
ret = dev->dev_ops->sym_session_configure(dev, xforms,
sess, mp);
if (ret < 0) {
@@ -1273,10 +1304,29 @@ rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts,
return mp;
}
+static unsigned int
+rte_cryptodev_sym_session_data_size(struct rte_cryptodev_sym_session *sess)
+{
+ return (sizeof(sess->sess_data[0]) * sess->nb_drivers);
+}
+
struct rte_cryptodev_sym_session *
rte_cryptodev_sym_session_create(struct rte_mempool *mp)
{
struct rte_cryptodev_sym_session *sess;
+ struct rte_cryptodev_sym_session_pool_private_data *pool_priv;
+
+ if (!mp) {
+ CDEV_LOG_ERR("Invalid mempool\n");
+ return NULL;
+ }
+
+ pool_priv = rte_mempool_get_priv(mp);
+
+ if (!pool_priv || mp->private_data_size < sizeof(*pool_priv)) {
+ CDEV_LOG_ERR("Invalid mempool\n");
+ return NULL;
+ }
/* Allocate a session structure from the session pool */
if (rte_mempool_get(mp, (void **)&sess)) {
@@ -1284,10 +1334,14 @@ rte_cryptodev_sym_session_create(struct rte_mempool *mp)
return NULL;
}
+ sess->nb_drivers = pool_priv->nb_drivers;
+
+
/* Clear device session pointer.
* Include the flag indicating presence of user data
*/
- memset(sess, 0, (sizeof(void *) * nb_drivers) + sizeof(uint8_t));
+ memset(sess->sess_data, 0,
+ rte_cryptodev_sym_session_data_size(sess));
return sess;
}
@@ -1395,16 +1449,20 @@ rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess)
return 0;
}
-
unsigned int
rte_cryptodev_sym_get_header_session_size(void)
{
/*
- * Header contains pointers to the private data
- * of all registered drivers, and a flag which
- * indicates presence of user data
+ * Header contains pointers to the private data of all registered
+ * drivers and all necessary information to ensure safely clear
+ * or free al session.
*/
- return ((sizeof(void *) * nb_drivers) + sizeof(uint8_t));
+ struct rte_cryptodev_sym_session s = {0};
+
+ s.nb_drivers = nb_drivers;
+
+ return (unsigned int)(sizeof(s) +
+ rte_cryptodev_sym_session_data_size(&s));
}
unsigned int
@@ -1414,7 +1472,8 @@ rte_cryptodev_sym_get_existing_header_session_size(
if (!sess)
return 0;
else
- return rte_cryptodev_sym_get_header_session_size();
+ return (unsigned int)(sizeof(*sess) +
+ rte_cryptodev_sym_session_data_size(sess));
}
unsigned int __rte_experimental
@@ -1432,7 +1491,6 @@ unsigned int
rte_cryptodev_sym_get_private_session_size(uint8_t dev_id)
{
struct rte_cryptodev *dev;
- unsigned int header_size = sizeof(void *) * nb_drivers;
unsigned int priv_sess_size;
if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
@@ -1445,16 +1503,7 @@ rte_cryptodev_sym_get_private_session_size(uint8_t dev_id)
priv_sess_size = (*dev->dev_ops->sym_session_get_size)(dev);
- /*
- * If size is less than session header size,
- * return the latter, as this guarantees that
- * sessionless operations will work
- */
- if (priv_sess_size < header_size)
- return header_size;
-
return priv_sess_size;
-
}
unsigned int __rte_experimental
@@ -1486,15 +1535,10 @@ rte_cryptodev_sym_session_set_user_data(
void *data,
uint16_t size)
{
- uint16_t off_set = sizeof(void *) * nb_drivers;
- uint8_t *user_data_present = (uint8_t *)sess + off_set;
-
if (sess == NULL)
return -EINVAL;
- *user_data_present = 1;
- off_set += sizeof(uint8_t);
- rte_memcpy((uint8_t *)sess + off_set, data, size);
+ rte_memcpy(sess->sess_data + sess->nb_drivers, data, size);
return 0;
}
@@ -1502,14 +1546,10 @@ void * __rte_experimental
rte_cryptodev_sym_session_get_user_data(
struct rte_cryptodev_sym_session *sess)
{
- uint16_t off_set = sizeof(void *) * nb_drivers;
- uint8_t *user_data_present = (uint8_t *)sess + off_set;
-
- if (sess == NULL || !*user_data_present)
+ if (sess == NULL)
return NULL;
- off_set += sizeof(uint8_t);
- return (uint8_t *)sess + off_set;
+ return (void *)(sess->sess_data + sess->nb_drivers);
}
/** Initialise rte_crypto_op mempool element */
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index c4db3aa0b..81b7fd1aa 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -957,8 +957,12 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
* has a fixed algo, key, op-type, digest_len etc.
*/
struct rte_cryptodev_sym_session {
- __extension__ void *sess_private_data[0];
- /**< Private symmetric session material */
+ uint16_t nb_drivers;
+ /**< number of elements in sess_data array */
+ __extension__ struct {
+ void *data;
+ } sess_data[0];
+ /**< Driver specific session material, variable size */
};
/** Cryptodev asymmetric crypto session */
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index f15c9af30..defe05ea0 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -475,14 +475,23 @@ RTE_INIT(init_ ##driver_id)\
static inline void *
get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess,
uint8_t driver_id) {
- return sess->sess_private_data[driver_id];
+ if (unlikely(sess->nb_drivers <= driver_id))
+ return NULL;
+
+ return sess->sess_data[driver_id].data;
}
static inline void
set_sym_session_private_data(struct rte_cryptodev_sym_session *sess,
uint8_t driver_id, void *private_data)
{
- sess->sess_private_data[driver_id] = private_data;
+ if (unlikely(sess->nb_drivers <= driver_id)) {
+ CDEV_LOG_ERR("Set private data for driver %u not allowed\n",
+ driver_id);
+ return;
+ }
+
+ sess->sess_data[driver_id].data = private_data;
}
static inline void *
--
2.13.6
next prev parent reply other threads:[~2019-01-09 22:56 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 17:24 [dpdk-dev] [PATCH 0/2] lib/cryptodev: change qp conf and sym session Fan Zhang
2018-11-15 17:24 ` [dpdk-dev] [PATCH 1/2] cryptodev: change queue pair configure structure Fan Zhang
2018-11-16 12:05 ` Ananyev, Konstantin
2018-11-19 10:12 ` Zhang, Roy Fan
2018-12-04 16:05 ` Trahe, Fiona
2018-11-15 17:24 ` [dpdk-dev] [PATCH 2/2] cryptodev: change symmetric session structure Fan Zhang
2018-11-16 0:47 ` Ananyev, Konstantin
2018-11-16 14:32 ` Ananyev, Konstantin
2018-11-19 10:11 ` Zhang, Roy Fan
2018-12-11 10:34 ` [dpdk-dev] [PATCH v2 0/2] lib/cryptodev: change qp conf and sym session Fan Zhang
2018-12-11 10:34 ` [dpdk-dev] [PATCH v2 1/2] cryptodev: change queue pair configure structure Fan Zhang
2018-12-17 19:31 ` Trahe, Fiona
2018-12-11 10:34 ` [dpdk-dev] [PATCH v2 2/2] cryptodev: change symmetric session structure Fan Zhang
2018-12-17 20:29 ` Trahe, Fiona
2018-12-18 16:25 ` Zhang, Roy Fan
2018-12-18 16:32 ` Trahe, Fiona
2018-12-11 12:26 ` [dpdk-dev] [PATCH v2 0/2] lib/cryptodev: change qp conf and sym session Ananyev, Konstantin
2018-12-21 13:55 ` [dpdk-dev] [PATCH v3 0/2] cryptodev: " Fan Zhang
2018-12-21 13:55 ` [dpdk-dev] [PATCH v3 1/2] cryptodev: change queue pair configure structure Fan Zhang
2019-01-08 23:20 ` De Lara Guarch, Pablo
2019-01-09 11:30 ` Zhang, Roy Fan
2019-01-09 10:41 ` De Lara Guarch, Pablo
2018-12-21 13:55 ` [dpdk-dev] [PATCH v3 2/2] cryptodev: change symmetric session structure Fan Zhang
2019-01-08 16:12 ` Trahe, Fiona
2019-01-09 11:01 ` De Lara Guarch, Pablo
2019-01-09 11:10 ` Zhang, Roy Fan
2019-01-09 22:55 ` [dpdk-dev] [PATCH v4 00/12] cryptodev: change qp conf and sym session Fan Zhang
2019-01-09 22:55 ` [dpdk-dev] [PATCH v4 01/12] cryptodev: change queue pair configure structure Fan Zhang
2019-01-10 9:47 ` De Lara Guarch, Pablo
2019-01-10 11:24 ` De Lara Guarch, Pablo
2019-01-09 22:55 ` [dpdk-dev] [PATCH v4 02/12] cryptodev: add sym session mempool create Fan Zhang
2019-01-10 11:22 ` De Lara Guarch, Pablo
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 03/12] app/test-crypto-perf: use separate session mempools Fan Zhang
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 04/12] net/softnic: " Fan Zhang
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 05/12] examples: " Fan Zhang
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 06/12] vhost/crypto: " Fan Zhang
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 07/12] test/crypto: " Fan Zhang
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 08/12] cryptodev: add sym session header size API Fan Zhang
2019-01-10 13:28 ` De Lara Guarch, Pablo
2019-01-09 22:56 ` Fan Zhang [this message]
2019-01-10 13:06 ` [dpdk-dev] [PATCH v4 09/12] cryptodev: update symmetric session structure De Lara Guarch, Pablo
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 10/12] cryptodev: add user data size to symmetric session Fan Zhang
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 11/12] cryptodev: add reference count to session private data Fan Zhang
2019-01-10 12:35 ` De Lara Guarch, Pablo
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 12/12] cryptodev: add opaque data field to symmetric session Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 00/12] cryptodev: change qp conf and sym session Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 01/12] cryptodev: change queue pair configure structure Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 02/12] cryptodev: add sym session mempool create Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 03/12] app/test-crypto-perf: use separate session mempools Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 04/12] net/softnic: " Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 05/12] examples: " Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 06/12] vhost/crypto: " Fan Zhang
2019-01-11 9:13 ` Maxime Coquelin
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 07/12] test/crypto: " Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 08/12] cryptodev: add sym session header size API Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 09/12] cryptodev: update symmetric session structure Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 10/12] cryptodev: add user data size to symmetric session Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 11/12] cryptodev: add reference count to session private data Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 12/12] cryptodev: add opaque data field to symmetric session Fan Zhang
2019-01-10 15:06 ` [dpdk-dev] [PATCH v5 00/12] cryptodev: change qp conf and sym session Akhil Goyal
2019-01-10 17:18 ` De Lara Guarch, Pablo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190109225609.20590-10-roy.fan.zhang@intel.com \
--to=roy.fan.zhang@intel.com \
--cc=akhil.goyal@nxp.com \
--cc=dev@dpdk.org \
--cc=fiona.trahe@intel.com \
--cc=pablo.de.lara.guarch@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).