| .. | .. |
|---|
| 85 | 85 | /* peak (theoretical) bulk transfer rate in bits-per-second */ |
|---|
| 86 | 86 | static inline unsigned ncm_bitrate(struct usb_gadget *g) |
|---|
| 87 | 87 | { |
|---|
| 88 | | - if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS) |
|---|
| 88 | + if (!g) |
|---|
| 89 | + return 0; |
|---|
| 90 | + else if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS) |
|---|
| 89 | 91 | return 4250000000U; |
|---|
| 90 | 92 | else if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER) |
|---|
| 91 | 93 | return 3750000000U; |
|---|
| .. | .. |
|---|
| 1178 | 1180 | struct sk_buff_head *list) |
|---|
| 1179 | 1181 | { |
|---|
| 1180 | 1182 | struct f_ncm *ncm = func_to_ncm(&port->func); |
|---|
| 1181 | | - __le16 *tmp = (void *) skb->data; |
|---|
| 1183 | + unsigned char *ntb_ptr = skb->data; |
|---|
| 1184 | + __le16 *tmp; |
|---|
| 1182 | 1185 | unsigned index, index2; |
|---|
| 1183 | 1186 | int ndp_index; |
|---|
| 1184 | 1187 | unsigned dg_len, dg_len2; |
|---|
| .. | .. |
|---|
| 1191 | 1194 | const struct ndp_parser_opts *opts = ncm->parser_opts; |
|---|
| 1192 | 1195 | unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; |
|---|
| 1193 | 1196 | int dgram_counter; |
|---|
| 1197 | + int to_process = skb->len; |
|---|
| 1198 | + |
|---|
| 1199 | +parse_ntb: |
|---|
| 1200 | + tmp = (__le16 *)ntb_ptr; |
|---|
| 1194 | 1201 | |
|---|
| 1195 | 1202 | /* dwSignature */ |
|---|
| 1196 | 1203 | if (get_unaligned_le32(tmp) != opts->nth_sign) { |
|---|
| .. | .. |
|---|
| 1237 | 1244 | * walk through NDP |
|---|
| 1238 | 1245 | * dwSignature |
|---|
| 1239 | 1246 | */ |
|---|
| 1240 | | - tmp = (void *)(skb->data + ndp_index); |
|---|
| 1247 | + tmp = (__le16 *)(ntb_ptr + ndp_index); |
|---|
| 1241 | 1248 | if (get_unaligned_le32(tmp) != ncm->ndp_sign) { |
|---|
| 1242 | 1249 | INFO(port->func.config->cdev, "Wrong NDP SIGN\n"); |
|---|
| 1243 | 1250 | goto err; |
|---|
| .. | .. |
|---|
| 1294 | 1301 | if (ncm->is_crc) { |
|---|
| 1295 | 1302 | uint32_t crc, crc2; |
|---|
| 1296 | 1303 | |
|---|
| 1297 | | - crc = get_unaligned_le32(skb->data + |
|---|
| 1304 | + crc = get_unaligned_le32(ntb_ptr + |
|---|
| 1298 | 1305 | index + dg_len - |
|---|
| 1299 | 1306 | crc_len); |
|---|
| 1300 | 1307 | crc2 = ~crc32_le(~0, |
|---|
| 1301 | | - skb->data + index, |
|---|
| 1308 | + ntb_ptr + index, |
|---|
| 1302 | 1309 | dg_len - crc_len); |
|---|
| 1303 | 1310 | if (crc != crc2) { |
|---|
| 1304 | 1311 | INFO(port->func.config->cdev, |
|---|
| .. | .. |
|---|
| 1325 | 1332 | dg_len - crc_len); |
|---|
| 1326 | 1333 | if (skb2 == NULL) |
|---|
| 1327 | 1334 | goto err; |
|---|
| 1328 | | - skb_put_data(skb2, skb->data + index, |
|---|
| 1335 | + skb_put_data(skb2, ntb_ptr + index, |
|---|
| 1329 | 1336 | dg_len - crc_len); |
|---|
| 1330 | 1337 | |
|---|
| 1331 | 1338 | skb_queue_tail(list, skb2); |
|---|
| .. | .. |
|---|
| 1338 | 1345 | } while (ndp_len > 2 * (opts->dgram_item_len * 2)); |
|---|
| 1339 | 1346 | } while (ndp_index); |
|---|
| 1340 | 1347 | |
|---|
| 1341 | | - dev_consume_skb_any(skb); |
|---|
| 1342 | | - |
|---|
| 1343 | 1348 | VDBG(port->func.config->cdev, |
|---|
| 1344 | 1349 | "Parsed NTB with %d frames\n", dgram_counter); |
|---|
| 1350 | + |
|---|
| 1351 | + to_process -= block_len; |
|---|
| 1352 | + if (to_process != 0) { |
|---|
| 1353 | + ntb_ptr = (unsigned char *)(ntb_ptr + block_len); |
|---|
| 1354 | + goto parse_ntb; |
|---|
| 1355 | + } |
|---|
| 1356 | + |
|---|
| 1357 | + dev_consume_skb_any(skb); |
|---|
| 1358 | + |
|---|
| 1345 | 1359 | return 0; |
|---|
| 1346 | 1360 | err: |
|---|
| 1347 | 1361 | skb_queue_purge(list); |
|---|