Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net-core: use netdev_* calls for kernel messages

While loading a driver and changing the number of queues, I noticed this
message in the kernel log:

"[253489.070080] Number of in use tx queues changed invalidating tc
mappings. Priority traffic classification disabled!"

But I had no idea what interface was being talked about because this
message used pr_warn().

After investigating, it appears we can use the netdev_* helpers already
defined to create predictably formatted messages, and that already handle
<unknown netdev> cases, in more of the messages in dev.c.

After this change, this message (and others) will look like this:
"[ 170.181093] ice 0000:3b:00.0 ens785f0: Number of in use tx queues
changed invalidating tc mappings. Priority traffic classification
disabled!"

One goal here was not to change the message significantly from the
original format so as to not break user's expectations, so I just
changed messages that used pr_* and generally started with %s ==
dev->name.

Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jesse Brandeburg and committed by
David S. Miller
5b92be64 0f00e70e

+10 -12
+10 -12
net/core/dev.c
··· 1296 1296 old_assign_type = NET_NAME_RENAMED; 1297 1297 goto rollback; 1298 1298 } else { 1299 - pr_err("%s: name change rollback failed: %d\n", 1300 - dev->name, ret); 1299 + netdev_err(dev, "name change rollback failed: %d\n", 1300 + ret); 1301 1301 } 1302 1302 } 1303 1303 ··· 2351 2351 2352 2352 /* If TC0 is invalidated disable TC mapping */ 2353 2353 if (tc->offset + tc->count > txq) { 2354 - pr_warn("Number of in use tx queues changed invalidating tc mappings. Priority traffic classification disabled!\n"); 2354 + netdev_warn(dev, "Number of in use tx queues changed invalidating tc mappings. Priority traffic classification disabled!\n"); 2355 2355 dev->num_tc = 0; 2356 2356 return; 2357 2357 } ··· 2362 2362 2363 2363 tc = &dev->tc_to_txq[q]; 2364 2364 if (tc->offset + tc->count > txq) { 2365 - pr_warn("Number of in use tx queues changed. Priority %i to tc mapping %i is no longer valid. Setting map to 0\n", 2366 - i, q); 2365 + netdev_warn(dev, "Number of in use tx queues changed. Priority %i to tc mapping %i is no longer valid. Setting map to 0\n", 2366 + i, q); 2367 2367 netdev_set_prio_tc_map(dev, i, 0); 2368 2368 } 2369 2369 } ··· 3416 3416 #ifdef CONFIG_BUG 3417 3417 static void do_netdev_rx_csum_fault(struct net_device *dev, struct sk_buff *skb) 3418 3418 { 3419 - pr_err("%s: hw csum failure\n", dev ? dev->name : "<unknown>"); 3419 + netdev_err(dev, "hw csum failure\n"); 3420 3420 skb_dump(KERN_ERR, skb, true); 3421 3421 dump_stack(); 3422 3422 } ··· 7012 7012 } 7013 7013 7014 7014 if (unlikely(work > weight)) 7015 - pr_err_once("NAPI poll function %pS returned %d, exceeding its budget of %d.\n", 7016 - n->poll, work, weight); 7015 + netdev_err_once(n->dev, "NAPI poll function %pS returned %d, exceeding its budget of %d.\n", 7016 + n->poll, work, weight); 7017 7017 7018 7018 if (likely(work < weight)) 7019 7019 return work; ··· 8567 8567 dev->flags &= ~IFF_PROMISC; 8568 8568 else { 8569 8569 dev->promiscuity -= inc; 8570 - pr_warn("%s: promiscuity touches roof, set promiscuity failed. promiscuity feature of device might be broken.\n", 8571 - dev->name); 8570 + netdev_warn(dev, "promiscuity touches roof, set promiscuity failed. promiscuity feature of device might be broken.\n"); 8572 8571 return -EOVERFLOW; 8573 8572 } 8574 8573 } ··· 8637 8638 dev->flags &= ~IFF_ALLMULTI; 8638 8639 else { 8639 8640 dev->allmulti -= inc; 8640 - pr_warn("%s: allmulti touches roof, set allmulti failed. allmulti feature of device might be broken.\n", 8641 - dev->name); 8641 + netdev_warn(dev, "allmulti touches roof, set allmulti failed. allmulti feature of device might be broken.\n"); 8642 8642 return -EOVERFLOW; 8643 8643 } 8644 8644 }