acassis commented on a change in pull request #3163:
URL: https://github.com/apache/incubator-nuttx/pull/3163#discussion_r600423373



##########
File path: drivers/usbdev/rndis.c
##########
@@ -1384,11 +1389,16 @@ rndis_prepare_response(FAR struct rndis_dev_s *priv, 
size_t size,
  *
  ****************************************************************************/
 
-static int rndis_send_encapsulated_response(FAR struct rndis_dev_s *priv)
+static int rndis_send_encapsulated_response(FAR struct rndis_dev_s *priv, 
size_t size)
 {
   FAR struct rndis_notification *notif =
     (FAR struct rndis_notification *)priv->epintin_req->buf;
 
+  /* Mark the response as available in the queue */
+  priv->response_queue_bytes += size;

Review comment:
       Please include an empty line after the comment line, it is part of the 
Coding Style.

##########
File path: drivers/usbdev/rndis.c
##########
@@ -1384,11 +1389,16 @@ rndis_prepare_response(FAR struct rndis_dev_s *priv, 
size_t size,
  *
  ****************************************************************************/
 
-static int rndis_send_encapsulated_response(FAR struct rndis_dev_s *priv)
+static int rndis_send_encapsulated_response(FAR struct rndis_dev_s *priv, 
size_t size)
 {
   FAR struct rndis_notification *notif =
     (FAR struct rndis_notification *)priv->epintin_req->buf;
 
+  /* Mark the response as available in the queue */
+  priv->response_queue_bytes += size;
+  DEBUGASSERT(priv->response_queue_bytes <= RNDIS_RESP_QUEUE_LEN);
+
+  /* Send notification on IRQ endpoint, to tell host to read the data. */

Review comment:
       Ditto

##########
File path: drivers/usbdev/rndis.c
##########
@@ -1738,15 +1746,27 @@ static void rndis_wrcomplete(FAR struct usbdev_ep_s *ep,
 static void usbclass_ep0incomplete(FAR struct usbdev_ep_s *ep,
                                    FAR struct usbdev_req_s *req)
 {
+  struct rndis_dev_s *priv = (FAR struct rndis_dev_s *)ep->priv;
   if (req->result || req->xfrd != req->len)
     {
       usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_REQRESULT),
                (uint16_t)-req->result);
     }
-  else if (req->len > 0)
+  else if (req->len > 0 && req->priv == priv->response_queue)
     {
-      struct rndis_dev_s *priv = (FAR struct rndis_dev_s *)ep->priv;
-      priv->ctrlreq_has_encap_response = false;
+      /* This transfer was from the response queue, subtract remaining byte 
count. */
+      req->priv = 0;

Review comment:
       Please add an empty line before and after the comment line.

##########
File path: drivers/usbdev/rndis.c
##########
@@ -1738,15 +1746,27 @@ static void rndis_wrcomplete(FAR struct usbdev_ep_s *ep,
 static void usbclass_ep0incomplete(FAR struct usbdev_ep_s *ep,
                                    FAR struct usbdev_req_s *req)
 {
+  struct rndis_dev_s *priv = (FAR struct rndis_dev_s *)ep->priv;
   if (req->result || req->xfrd != req->len)
     {
       usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_REQRESULT),
                (uint16_t)-req->result);
     }
-  else if (req->len > 0)
+  else if (req->len > 0 && req->priv == priv->response_queue)
     {
-      struct rndis_dev_s *priv = (FAR struct rndis_dev_s *)ep->priv;
-      priv->ctrlreq_has_encap_response = false;
+      /* This transfer was from the response queue, subtract remaining byte 
count. */
+      req->priv = 0;
+      if (req->len >= priv->response_queue_bytes)
+      {
+        /* Queue now empty */
+        priv->response_queue_bytes = 0;
+      }
+      else
+      {
+        /* Copy the remaining responses to beginning of buffer. */

Review comment:
       Ditto

##########
File path: drivers/usbdev/rndis.c
##########
@@ -1738,15 +1746,27 @@ static void rndis_wrcomplete(FAR struct usbdev_ep_s *ep,
 static void usbclass_ep0incomplete(FAR struct usbdev_ep_s *ep,
                                    FAR struct usbdev_req_s *req)
 {
+  struct rndis_dev_s *priv = (FAR struct rndis_dev_s *)ep->priv;
   if (req->result || req->xfrd != req->len)
     {
       usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_REQRESULT),
                (uint16_t)-req->result);
     }
-  else if (req->len > 0)
+  else if (req->len > 0 && req->priv == priv->response_queue)
     {
-      struct rndis_dev_s *priv = (FAR struct rndis_dev_s *)ep->priv;
-      priv->ctrlreq_has_encap_response = false;
+      /* This transfer was from the response queue, subtract remaining byte 
count. */
+      req->priv = 0;
+      if (req->len >= priv->response_queue_bytes)
+      {
+        /* Queue now empty */
+        priv->response_queue_bytes = 0;

Review comment:
       Ditto

##########
File path: drivers/usbdev/rndis.c
##########
@@ -2194,6 +2214,9 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s 
*driver,
       leave_critical_section(flags);
     }
 
+  /* Initialize response queue to empty */
+  priv->response_queue_bytes = 0;

Review comment:
       Ditto

##########
File path: drivers/usbdev/rndis.c
##########
@@ -2474,20 +2498,19 @@ static int usbclass_setup(FAR struct 
usbdevclass_driver_s *driver,
               }
             else if (ctrl->req == RNDIS_GET_ENCAPSULATED_RESPONSE)
               {
-                if (!priv->ctrlreq_has_encap_response)
+                if (priv->response_queue_bytes == 0)
                   {
+                    /* No reply available is indicated with a single 0x00 
byte. */
                     ret = 1;
                     ctrlreq->buf[0] = 0;
                   }
                 else
                   {
-                    /* There is data prepared in the ctrlreq buffer.
-                     * Just assign the length.
-                     */
-
+                    /* Retrieve a single reply from the response queue to 
control request buffer. */

Review comment:
       Ditto




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to