1360 direct->di_tx_cb_df = (uintptr_t)mac_client_tx_notify;
1361 direct->di_tx_cb_dh = dsp->ds_mch;
1362 direct->di_tx_fctl_df = (uintptr_t)mac_tx_is_flow_blocked;
1363 direct->di_tx_fctl_dh = dsp->ds_mch;
1364
1365 dsp->ds_direct = B_TRUE;
1366
1367 return (0);
1368
1369 case DLD_DISABLE:
1370 dls_rx_set(dsp, (dsp->ds_mode == DLD_FASTPATH) ?
1371 dld_str_rx_fastpath : dld_str_rx_unitdata, (void *)dsp);
1372 dsp->ds_direct = B_FALSE;
1373
1374 return (0);
1375 }
1376 return (ENOTSUP);
1377 }
1378
1379 /*
1380 * dld_capab_poll_enable()
1381 *
1382 * This function is misnamed. All polling and fanouts are run out of the
1383 * lower mac (in case of VNIC and the only mac in case of NICs). The
1384 * availability of Rx ring and promiscous mode is all taken care between
1385 * the soft ring set (mac_srs), the Rx ring, and S/W classifier. Any
1386 * fanout necessary is done by the soft rings that are part of the
1387 * mac_srs (by default mac_srs sends the packets up via a TCP and
1388 * non TCP soft ring).
1389 *
1390 * The mac_srs (or its associated soft rings) always store the ill_rx_ring
1391 * (the cookie returned when they registered with IP during plumb) as their
1392 * 2nd argument which is passed up as mac_resource_handle_t. The upcall
1393 * function and 1st argument is what the caller registered when they
1394 * called mac_rx_classify_flow_add() to register the flow. For VNIC,
1395 * the function is vnic_rx and argument is vnic_t. For regular NIC
1396 * case, it mac_rx_default and mac_handle_t. As explained above, the
1397 * mac_srs (or its soft ring) will add the ill_rx_ring (mac_resource_handle_t)
1398 * from its stored 2nd argument.
1399 */
1400 static int
1401 dld_capab_poll_enable(dld_str_t *dsp, dld_capab_poll_t *poll)
1402 {
1403 if (dsp->ds_polling)
1404 return (EINVAL);
1405
1406 if ((dld_opt & DLD_OPT_NO_POLL) != 0 || dsp->ds_mode == DLD_RAW)
1407 return (ENOTSUP);
1408
1409 /*
1410 * Enable client polling if and only if DLS bypass is possible.
1411 * Special cases like VLANs need DLS processing in the Rx data path.
1412 * In such a case we can neither allow the client (IP) to directly
1413 * poll the softring (since DLS processing hasn't been done) nor can
1414 * we allow DLS bypass.
1415 */
1416 if (!mac_rx_bypass_set(dsp->ds_mch, dsp->ds_rx, dsp->ds_rx_arg))
1417 return (ENOTSUP);
1418
1419 /*
1420 * Register soft ring resources. This will come in handy later if
1421 * the user decides to modify CPU bindings to use more CPUs for the
1422 * device in which case we will switch to fanout using soft rings.
1423 */
1424 mac_resource_set_common(dsp->ds_mch,
1425 (mac_resource_add_t)poll->poll_ring_add_cf,
1426 (mac_resource_remove_t)poll->poll_ring_remove_cf,
1427 (mac_resource_quiesce_t)poll->poll_ring_quiesce_cf,
1428 (mac_resource_restart_t)poll->poll_ring_restart_cf,
1429 (mac_resource_bind_t)poll->poll_ring_bind_cf,
1430 poll->poll_ring_ch);
1431
1432 mac_client_poll_enable(dsp->ds_mch);
1433
1434 dsp->ds_polling = B_TRUE;
|
1360 direct->di_tx_cb_df = (uintptr_t)mac_client_tx_notify;
1361 direct->di_tx_cb_dh = dsp->ds_mch;
1362 direct->di_tx_fctl_df = (uintptr_t)mac_tx_is_flow_blocked;
1363 direct->di_tx_fctl_dh = dsp->ds_mch;
1364
1365 dsp->ds_direct = B_TRUE;
1366
1367 return (0);
1368
1369 case DLD_DISABLE:
1370 dls_rx_set(dsp, (dsp->ds_mode == DLD_FASTPATH) ?
1371 dld_str_rx_fastpath : dld_str_rx_unitdata, (void *)dsp);
1372 dsp->ds_direct = B_FALSE;
1373
1374 return (0);
1375 }
1376 return (ENOTSUP);
1377 }
1378
1379 /*
1380 * This function is misnamed. All polling and fanouts are run out of
1381 * the lower MAC for VNICs and out of the MAC for NICs. The
1382 * availability of Rx rings and promiscous mode is taken care of
1383 * between the soft ring set (mac_srs), the Rx ring, and the SW
1384 * classifier. Fanout, if necessary, is done by the soft rings that
1385 * are part of the SRS. By default the SRS divvies up the packets
1386 * based on protocol: TCP, UDP, or Other (OTH).
1387 *
1388 * The SRS (or its associated soft rings) always store the ill_rx_ring
1389 * (the cookie returned when they registered with IP during plumb) as their
1390 * 2nd argument which is passed up as mac_resource_handle_t. The upcall
1391 * function and 1st argument is what the caller registered when they
1392 * called mac_rx_classify_flow_add() to register the flow. For VNIC,
1393 * the function is vnic_rx and argument is vnic_t. For regular NIC
1394 * case, it mac_rx_default and mac_handle_t. As explained above, the
1395 * SRS (or its soft ring) will add the ill_rx_ring (mac_resource_handle_t)
1396 * from its stored 2nd argument.
1397 */
1398 static int
1399 dld_capab_poll_enable(dld_str_t *dsp, dld_capab_poll_t *poll)
1400 {
1401 if (dsp->ds_polling)
1402 return (EINVAL);
1403
1404 if ((dld_opt & DLD_OPT_NO_POLL) != 0 || dsp->ds_mode == DLD_RAW)
1405 return (ENOTSUP);
1406
1407 /*
1408 * Enable client polling if and only if DLS bypass is
1409 * possible. Some traffic requires DLS processing in the Rx
1410 * data path. In such a case we can neither allow the client
1411 * (IP) to directly poll the soft ring (since DLS processing
1412 * hasn't been done) nor can we allow DLS bypass.
1413 */
1414 if (!mac_rx_bypass_set(dsp->ds_mch, dsp->ds_rx, dsp->ds_rx_arg))
1415 return (ENOTSUP);
1416
1417 /*
1418 * Register soft ring resources. This will come in handy later if
1419 * the user decides to modify CPU bindings to use more CPUs for the
1420 * device in which case we will switch to fanout using soft rings.
1421 */
1422 mac_resource_set_common(dsp->ds_mch,
1423 (mac_resource_add_t)poll->poll_ring_add_cf,
1424 (mac_resource_remove_t)poll->poll_ring_remove_cf,
1425 (mac_resource_quiesce_t)poll->poll_ring_quiesce_cf,
1426 (mac_resource_restart_t)poll->poll_ring_restart_cf,
1427 (mac_resource_bind_t)poll->poll_ring_bind_cf,
1428 poll->poll_ring_ch);
1429
1430 mac_client_poll_enable(dsp->ds_mch);
1431
1432 dsp->ds_polling = B_TRUE;
|