Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
0002 /* Copyright (C) 2019 Netronome Systems, Inc. */
0003 
0004 #include <linux/proc_fs.h>
0005 #include <linux/seq_file.h>
0006 #include <net/snmp.h>
0007 #include <net/tls.h>
0008 
0009 #include "tls.h"
0010 
0011 #ifdef CONFIG_PROC_FS
0012 static const struct snmp_mib tls_mib_list[] = {
0013     SNMP_MIB_ITEM("TlsCurrTxSw", LINUX_MIB_TLSCURRTXSW),
0014     SNMP_MIB_ITEM("TlsCurrRxSw", LINUX_MIB_TLSCURRRXSW),
0015     SNMP_MIB_ITEM("TlsCurrTxDevice", LINUX_MIB_TLSCURRTXDEVICE),
0016     SNMP_MIB_ITEM("TlsCurrRxDevice", LINUX_MIB_TLSCURRRXDEVICE),
0017     SNMP_MIB_ITEM("TlsTxSw", LINUX_MIB_TLSTXSW),
0018     SNMP_MIB_ITEM("TlsRxSw", LINUX_MIB_TLSRXSW),
0019     SNMP_MIB_ITEM("TlsTxDevice", LINUX_MIB_TLSTXDEVICE),
0020     SNMP_MIB_ITEM("TlsRxDevice", LINUX_MIB_TLSRXDEVICE),
0021     SNMP_MIB_ITEM("TlsDecryptError", LINUX_MIB_TLSDECRYPTERROR),
0022     SNMP_MIB_ITEM("TlsRxDeviceResync", LINUX_MIB_TLSRXDEVICERESYNC),
0023     SNMP_MIB_ITEM("TlsDecryptRetry", LINUX_MIB_TLSDECRYPTRETRY),
0024     SNMP_MIB_ITEM("TlsRxNoPadViolation", LINUX_MIB_TLSRXNOPADVIOL),
0025     SNMP_MIB_SENTINEL
0026 };
0027 
0028 static int tls_statistics_seq_show(struct seq_file *seq, void *v)
0029 {
0030     unsigned long buf[LINUX_MIB_TLSMAX] = {};
0031     struct net *net = seq->private;
0032     int i;
0033 
0034     snmp_get_cpu_field_batch(buf, tls_mib_list, net->mib.tls_statistics);
0035     for (i = 0; tls_mib_list[i].name; i++)
0036         seq_printf(seq, "%-32s\t%lu\n", tls_mib_list[i].name, buf[i]);
0037 
0038     return 0;
0039 }
0040 #endif
0041 
0042 int __net_init tls_proc_init(struct net *net)
0043 {
0044 #ifdef CONFIG_PROC_FS
0045     if (!proc_create_net_single("tls_stat", 0444, net->proc_net,
0046                     tls_statistics_seq_show, NULL))
0047         return -ENOMEM;
0048 #endif /* CONFIG_PROC_FS */
0049 
0050     return 0;
0051 }
0052 
0053 void __net_exit tls_proc_fini(struct net *net)
0054 {
0055     remove_proc_entry("tls_stat", net->proc_net);
0056 }