Home
last modified time | relevance | path

Searched hist:"99132 b6e" (Results 1 – 3 of 3) sorted by relevance

/openbmc/linux/net/ethtool/
H A Dpause.c99132b6e Wed Jan 25 17:05:18 CST 2023 Jakub Kicinski <kuba@kernel.org> ethtool: netlink: handle SET intro/outro in the common code

Most ethtool SET callbacks follow the same general structure.

ethnl_parse_header_dev_get()
rtnl_lock()
ethnl_ops_begin()

... do stuff ...

ethtool_notify()
ethnl_ops_complete()
rtnl_unlock()
ethnl_parse_header_dev_put()

This leads to a lot of copy / pasted code an bugs when people
mis-handle the error path.

Add a generic implementation of this pattern with a .set callback
in struct ethnl_request_ops called to "do stuff".

Also add an optional .set_validate which is called before
ethnl_ops_begin() -- a lot of implementations do basic request
capability / sanity checking at that point.

Because we want to avoid generating the notification when
no change happened - adopt a slightly hairy return values:
- 0 means nothing to do (no notification)
- 1 means done / continue
- negative error codes on error

Reuse .hdr_attr from struct ethnl_request_ops, GET and SET
use the same attr spaces in all cases.

Convert pause as an example (and to avoid unused function warnings).

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
H A Dnetlink.h99132b6e Wed Jan 25 17:05:18 CST 2023 Jakub Kicinski <kuba@kernel.org> ethtool: netlink: handle SET intro/outro in the common code

Most ethtool SET callbacks follow the same general structure.

ethnl_parse_header_dev_get()
rtnl_lock()
ethnl_ops_begin()

... do stuff ...

ethtool_notify()
ethnl_ops_complete()
rtnl_unlock()
ethnl_parse_header_dev_put()

This leads to a lot of copy / pasted code an bugs when people
mis-handle the error path.

Add a generic implementation of this pattern with a .set callback
in struct ethnl_request_ops called to "do stuff".

Also add an optional .set_validate which is called before
ethnl_ops_begin() -- a lot of implementations do basic request
capability / sanity checking at that point.

Because we want to avoid generating the notification when
no change happened - adopt a slightly hairy return values:
- 0 means nothing to do (no notification)
- 1 means done / continue
- negative error codes on error

Reuse .hdr_attr from struct ethnl_request_ops, GET and SET
use the same attr spaces in all cases.

Convert pause as an example (and to avoid unused function warnings).

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
H A Dnetlink.c99132b6e Wed Jan 25 17:05:18 CST 2023 Jakub Kicinski <kuba@kernel.org> ethtool: netlink: handle SET intro/outro in the common code

Most ethtool SET callbacks follow the same general structure.

ethnl_parse_header_dev_get()
rtnl_lock()
ethnl_ops_begin()

... do stuff ...

ethtool_notify()
ethnl_ops_complete()
rtnl_unlock()
ethnl_parse_header_dev_put()

This leads to a lot of copy / pasted code an bugs when people
mis-handle the error path.

Add a generic implementation of this pattern with a .set callback
in struct ethnl_request_ops called to "do stuff".

Also add an optional .set_validate which is called before
ethnl_ops_begin() -- a lot of implementations do basic request
capability / sanity checking at that point.

Because we want to avoid generating the notification when
no change happened - adopt a slightly hairy return values:
- 0 means nothing to do (no notification)
- 1 means done / continue
- negative error codes on error

Reuse .hdr_attr from struct ethnl_request_ops, GET and SET
use the same attr spaces in all cases.

Convert pause as an example (and to avoid unused function warnings).

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>