diff mbox series

[RFC,net-next,v5,09/10] net: txgbe: add devlink and devlink port created

Message ID B9735D5509541210+20240726100301.21416-10-mengyuanlou@net-swift.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series add sriov support for wangxun NICs | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 42 this patch: 42
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 4 maintainers not CCed: jiawenwu@trustnetic.com edumazet@google.com pabeni@redhat.com kuba@kernel.org
netdev/build_clang success Errors and warnings before: 43 this patch: 43
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 43 this patch: 43
netdev/checkpatch warning WARNING: Missing commit description - Add an appropriate one
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 6 this patch: 6
netdev/source_inline success Was 0 now: 0

Commit Message

Mengyuan Lou July 26, 2024, 10:03 a.m. UTC
Signed-off-by: Mengyuan Lou <mengyuanlou@net-swift.com>
---
 .../net/ethernet/wangxun/txgbe/txgbe_main.c    | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
index c95d0611cf25..bf9756814f76 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
@@ -16,6 +16,7 @@ 
 #include "../libwx/wx_hw.h"
 #include "../libwx/wx_mbx.h"
 #include "../libwx/wx_sriov.h"
+#include "../libwx/wx_devlink.h"
 #include "txgbe_type.h"
 #include "txgbe_hw.h"
 #include "txgbe_phy.h"
@@ -564,6 +565,13 @@  static int txgbe_probe(struct pci_dev *pdev,
 	wx->netdev = netdev;
 	wx->pdev = pdev;
 
+	wx->dl_priv = wx_create_devlink(&pdev->dev);
+	if (!wx->dl_priv) {
+		err = -ENOMEM;
+		goto err_pci_release_regions;
+	}
+
+	wx->dl_priv->priv_wx = wx;
 	wx->msg_enable = (1 << DEFAULT_DEBUG_LEVEL_SHIFT) - 1;
 
 	wx->hw_addr = devm_ioremap(&pdev->dev,
@@ -707,9 +715,14 @@  static int txgbe_probe(struct pci_dev *pdev,
 	if (err)
 		goto err_free_misc_irq;
 
-	err = register_netdev(netdev);
+	err = wx_devlink_create_pf_port(wx);
 	if (err)
 		goto err_remove_phy;
+	SET_NETDEV_DEVLINK_PORT(netdev, &wx->devlink_port);
+
+	err = register_netdev(netdev);
+	if (err)
+		goto err_devlink_create_pf_port;
 
 	pci_set_drvdata(pdev, wx);
 
@@ -731,6 +744,8 @@  static int txgbe_probe(struct pci_dev *pdev,
 
 	return 0;
 
+err_devlink_create_pf_port:
+	devl_port_unregister(&wx->devlink_port);
 err_remove_phy:
 	txgbe_remove_phy(txgbe);
 err_free_misc_irq:
@@ -767,6 +782,7 @@  static void txgbe_remove(struct pci_dev *pdev)
 	wx_disable_sriov(wx);
 	unregister_netdev(netdev);
 
+	devl_port_unregister(&wx->devlink_port);
 	txgbe_remove_phy(txgbe);
 	txgbe_free_misc_irq(txgbe);
 	wx_free_isb_resources(wx);