Skip to content

Commit 11df3a7

Browse files
sodarferruhy
authored andcommitted
ethdev: add get restore flags driver callback
Before this patch, ethdev layer assumed that all drivers require that it has to forcefully restore: - MAC addresses - promiscuous mode setting - all multicast mode setting upon rte_eth_dev_start(). This patch introduces a new callback to eth_dev_ops - get_restore_flags(). Drivers implementing this callback can explicitly enable/disable certain parts of config restore procedure. In order to minimize the changes to all the drivers and preserve the current behavior, it is assumed that if this callback is not defined, all configuration should be restored. Signed-off-by: Dariusz Sosnowski <[email protected]> Acked-by: Ferruh Yigit <[email protected]>
1 parent d1f201a commit 11df3a7

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

lib/ethdev/ethdev_driver.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,3 +958,12 @@ rte_eth_switch_domain_free(uint16_t domain_id)
958958

959959
return 0;
960960
}
961+
962+
uint64_t
963+
rte_eth_get_restore_flags(struct rte_eth_dev *dev, enum rte_eth_dev_operation op)
964+
{
965+
if (dev->dev_ops->get_restore_flags != NULL)
966+
return dev->dev_ops->get_restore_flags(dev, op);
967+
else
968+
return RTE_ETH_RESTORE_ALL;
969+
}

lib/ethdev/ethdev_driver.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,48 @@ typedef int (*eth_count_aggr_ports_t)(struct rte_eth_dev *dev);
13221322
typedef int (*eth_map_aggr_tx_affinity_t)(struct rte_eth_dev *dev, uint16_t tx_queue_id,
13231323
uint8_t affinity);
13241324

1325+
/**
1326+
* @internal
1327+
* Defines types of operations which can be executed by the application.
1328+
*/
1329+
enum rte_eth_dev_operation {
1330+
RTE_ETH_START,
1331+
};
1332+
1333+
/**@{@name Restore flags
1334+
* Flags returned by get_restore_flags() callback.
1335+
* They indicate to ethdev layer which configuration is required to be restored.
1336+
*/
1337+
/** If set, ethdev layer will forcefully restore default and any other added MAC addresses. */
1338+
#define RTE_ETH_RESTORE_MAC_ADDR RTE_BIT64(0)
1339+
/** If set, ethdev layer will forcefully restore current promiscuous mode setting. */
1340+
#define RTE_ETH_RESTORE_PROMISC RTE_BIT64(1)
1341+
/** If set, ethdev layer will forcefully restore current all multicast mode setting. */
1342+
#define RTE_ETH_RESTORE_ALLMULTI RTE_BIT64(2)
1343+
/**@}*/
1344+
1345+
/** All configuration which can be restored by ethdev layer. */
1346+
#define RTE_ETH_RESTORE_ALL (RTE_ETH_RESTORE_MAC_ADDR | \
1347+
RTE_ETH_RESTORE_PROMISC | \
1348+
RTE_ETH_RESTORE_ALLMULTI)
1349+
1350+
/**
1351+
* @internal
1352+
* Fetch from the driver what kind of configuration must be restored by ethdev layer,
1353+
* after certain operations are performed by the application (such as rte_eth_dev_start()).
1354+
*
1355+
* @param dev
1356+
* Port (ethdev) handle.
1357+
* @param op
1358+
* Type of operation executed by the application.
1359+
*
1360+
* @return
1361+
* ORed restore flags indicating which configuration should be restored by ethdev.
1362+
* 0 if no restore is required by the driver.
1363+
*/
1364+
typedef uint64_t (*eth_get_restore_flags_t)(struct rte_eth_dev *dev,
1365+
enum rte_eth_dev_operation op);
1366+
13251367
/**
13261368
* @internal A structure containing the functions exported by an Ethernet driver.
13271369
*/
@@ -1565,6 +1607,9 @@ struct eth_dev_ops {
15651607
eth_count_aggr_ports_t count_aggr_ports;
15661608
/** Map a Tx queue with an aggregated port of the DPDK port */
15671609
eth_map_aggr_tx_affinity_t map_aggr_tx_affinity;
1610+
1611+
/** Get configuration which ethdev should restore */
1612+
eth_get_restore_flags_t get_restore_flags;
15681613
};
15691614

15701615
/**
@@ -2222,6 +2267,27 @@ struct rte_eth_fdir_conf {
22222267
struct rte_eth_fdir_flex_conf flex_conf;
22232268
};
22242269

2270+
/**
2271+
* @internal
2272+
* Fetch from the driver what kind of configuration must be restored by ethdev layer,
2273+
* using get_restore_flags() callback.
2274+
*
2275+
* If callback is not defined, it is assumed that all supported configuration must be restored.
2276+
*
2277+
* @param dev
2278+
* Port (ethdev) handle.
2279+
* @param op
2280+
* Type of operation executed by the application.
2281+
*
2282+
* @return
2283+
* ORed restore flags indicating which configuration should be restored by ethdev.
2284+
* 0 if no restore is required by the driver.
2285+
*/
2286+
__rte_internal
2287+
uint64_t
2288+
rte_eth_get_restore_flags(struct rte_eth_dev *dev,
2289+
enum rte_eth_dev_operation op);
2290+
22252291
#ifdef __cplusplus
22262292
}
22272293
#endif

lib/ethdev/version.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,5 @@ INTERNAL {
368368
rte_eth_switch_domain_alloc;
369369
rte_eth_switch_domain_free;
370370
rte_flow_fp_default_ops;
371+
rte_eth_get_restore_flags;
371372
};

0 commit comments

Comments
 (0)